mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Armin Wolf <W_Armin@gmx.de>, hdegoede@redhat.com
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] hwmon: (sch56xx-common) Replace msleep() with usleep_range()
Date: Mon, 31 Jan 2022 12:10:12 -0800	[thread overview]
Message-ID: <3af7602a-1703-4ff2-3905-dfd35742dd90@roeck-us.net> (raw)
In-Reply-To: <20220131193137.3684-4-W_Armin@gmx.de>

On 1/31/22 11:31, Armin Wolf wrote:
> msleep(1) will often sleep more than 20ms, slowing down sensor
> and watchdog reads/writes. Use usleep_range() as recommended
> in timers-howto.rst to fix that.
> 
> Tested on a Fujitsu Esprimo P720.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>   drivers/hwmon/sch56xx-common.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
> index 0172aa16dc0c..f66e1ed4b1aa 100644
> --- a/drivers/hwmon/sch56xx-common.c
> +++ b/drivers/hwmon/sch56xx-common.c
> @@ -139,7 +139,7 @@ static int sch56xx_send_cmd(u16 addr, u8 cmd, u16 reg, u8 v)
>   	/* EM Interface Polling "Algorithm" */
>   	for (i = 0; i < max_busy_polls + max_lazy_polls; i++) {
>   		if (i >= max_busy_polls)
> -			msleep(1);
> +			usleep_range(1, 2);

This replaces a 1-millisecond sleep with a 1-2 microsecond sleep.

Are you sure this is what you want to do ? Given that task switches typically
take several microseconds, the new code is pretty much identical to a busy
loop, and the maximum sleep time is reduced significantly.

Guenter

>   		/* Read Interrupt source Register */
>   		val = inb(addr + 8);
>   		/* Write Clear the interrupt source bits */
> --
> 2.30.2
> 


  reply	other threads:[~2022-01-31 20:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-31 19:31 [PATCH v2 0/4] hwmon: (sch56xx) Automatically load on supported hardware Armin Wolf
2022-01-31 19:31 ` [PATCH v2 1/4] hwmon: (sch56xx) Autoload modules on platform device creation Armin Wolf
2022-01-31 19:31 ` [PATCH v2 2/4] hwmon: (sch56xx-common) Add automatic module loading on supported devices Armin Wolf
2022-01-31 19:31 ` [PATCH v2 3/4] hwmon: (sch56xx-common) Replace msleep() with usleep_range() Armin Wolf
2022-01-31 20:10   ` Guenter Roeck [this message]
2022-01-31 21:01     ` Hans de Goede
2022-01-31 19:31 ` [PATCH v2 4/4] hwmon: (sch56xx-common) Replace WDOG_ACTIVE with WDOG_HW_RUNNING Armin Wolf

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=3af7602a-1703-4ff2-3905-dfd35742dd90@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=W_Armin@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®