All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooks <andrew.cooks@opengear.com>
To: Guenter Roeck <linux@roeck-us.net>, Wolfram Sang <wsa@the-dreams.de>
Cc: "Jean Delvare" <jdelvare@suse.com>,
	"Zoltán Böszörményi" <zboszor@pr.hu>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] i2c: piix4: Use usleep_range()
Date: Thu, 22 Feb 2018 13:59:49 +1000	[thread overview]
Message-ID: <6af53537-f160-8ea5-2491-98f8a7966975@opengear.com> (raw)
In-Reply-To: <1514652658-6228-2-git-send-email-linux@roeck-us.net>


On 31/12/17 02:50, Guenter Roeck wrote:
> The piix4 i2c driver is extremely slow. Replacing msleep()
> with usleep_range() increases its speed substantially.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/i2c/busses/i2c-piix4.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 78dd5951d6e7..52a8b1c5c110 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -467,13 +467,13 @@ static int piix4_transaction(struct i2c_adapter *piix4_adapter)
>  
>  	/* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
>  	if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
> -		msleep(2);
> +		usleep_range(2000, 2000);
>  	else
> -		msleep(1);
> +		usleep_range(500, 1000);
>  
>  	while ((++timeout < MAX_TIMEOUT) &&
>  	       ((temp = inb_p(SMBHSTSTS)) & 0x01))
> -		msleep(1);
> +		usleep_range(200, 500);
>  
>  	/* If the SMBus is still busy, we give up */
>  	if (timeout == MAX_TIMEOUT) {
> 
Thanks for this patch.

FWIW, this also makes a noticeable difference on AMD Family 16h Model 30h, used in embedded designs and also commonly available as AMD GX-412TC SoC in the PC Engines APU2.

Among the tests I did were reading from the SoC temperature sensor in a loop:
while [ true ] ; do i2cget -y 0 0x4C 0x01 ; done

and scanning for peripherals in a loop:
while [ true ] ; do i2cdetect -y 0 ; done

These tests may be artificial and trivial, but the speedup matters to us because we have more than one bus master and the embedded controller needs to poll multiple sensors.

Tested-by: Andrew Cooks <andrew.cooks@opengear.com>

  parent reply	other threads:[~2018-02-22  4:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-30 16:50 [PATCH 1/2] i2c: piix4: Use request_muxed_region Guenter Roeck
2017-12-30 16:50 ` [PATCH 2/2] i2c: piix4: Use usleep_range() Guenter Roeck
2018-02-11 20:12   ` [2/2] " Guenter Roeck
2018-02-12 10:53   ` [PATCH 2/2] " Jean Delvare
2018-02-12 20:59     ` Guenter Roeck
2018-02-12 21:35       ` Joe Perches
2018-02-12 22:22     ` Guenter Roeck
2018-02-14 14:44       ` Jean Delvare
2018-02-26 19:56     ` Wolfram Sang
2018-02-22  3:59   ` Andrew Cooks [this message]
2018-02-11 20:11 ` [1/2] i2c: piix4: Use request_muxed_region Guenter Roeck
2018-02-12 10:10 ` [PATCH 1/2] " Jean Delvare
2018-02-12 18:51   ` Guenter Roeck
2018-02-13 11:48     ` Böszörményi Zoltán
2018-02-13 14:11       ` Guenter Roeck
2018-02-14 14:23     ` Jean Delvare
2018-02-26 19:55       ` Wolfram Sang
2018-02-26 20:37         ` Guenter Roeck

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=6af53537-f160-8ea5-2491-98f8a7966975@opengear.com \
    --to=andrew.cooks@opengear.com \
    --cc=jdelvare@suse.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=wsa@the-dreams.de \
    --cc=zboszor@pr.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.