public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Chunhe Lan <b25806@freescale.com>
Cc: Chunhe Lan <Chunhe.Lan@freescale.com>,
	linux-mmc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	kumar.gala@freescale.com, cjb@laptop.org,
	Kumar Gala <galak@kernel.crashing.org>
Subject: Re: [PATCH v3 1/2] mmc: Move mmc_delay() to include/linux/mmc/core.h
Date: Mon, 24 Sep 2012 13:17:32 +0000	[thread overview]
Message-ID: <201209241317.32425.arnd@arndb.de> (raw)
In-Reply-To: <50607A5A.3060103@freescale.com>

On Monday 24 September 2012, Chunhe Lan wrote:
>     OK. As you have mentioned, it would been modified to such:
> 
> static inline void mmc_delay(unsigned int ms)
> {
>          if (ms < 1000 / HZ) {
>                  cond_resched();
>                  msleep(ms);
>          } else {
>                  msleep(ms);
>          }
> }

This version would be rather broken, because it compares times
in two different units (ms and jiffies), and because it
does a cond_resched() directly before an msleep: both of which
end up calling schedule() and being away for some time,
cond_resched() for an unknown time, and msleep for a minimum
time on top of that.

> OR such:
> 
> static inline void mmc_delay(unsigned int ms)
> {
>           msleep(ms);
> }

That would be my preferred choice, unless someone has specific issues with this.

> OR other code?

Well, in principle, you could implement something like

static inline void mmc_delay(unsigned int ms)
{
	ktime_t end = ktime_add_us(ktime_get(), ms * 1000);

	while (1) {
		s64 remaining;

		cond_resched();

		remaining = ktime_to_us(ktime_sub(end, ktime_get()));

		if (remaining < 0)
			break;

		udelay(min_t(u32, remaining, 100));
	}
}

	Arnd

  reply	other threads:[~2012-09-24 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 22:25 [PATCH v3 1/2] mmc: Move mmc_delay() to include/linux/mmc/core.h Chunhe Lan
2012-08-10 13:27 ` Arnd Bergmann
2012-09-21 20:52   ` Chunhe Lan
2012-09-21 12:33     ` Arnd Bergmann
2012-09-24 15:20       ` Chunhe Lan
2012-09-24 13:17         ` Arnd Bergmann [this message]
2012-09-24 14:38           ` Tabi Timur-B04825

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=201209241317.32425.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=Chunhe.Lan@freescale.com \
    --cc=b25806@freescale.com \
    --cc=cjb@laptop.org \
    --cc=galak@kernel.crashing.org \
    --cc=kumar.gala@freescale.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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