public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Mason <slash.tmp@free.fr>
To: linux-mtd@lists.infradead.org
Cc: Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Tiny delays in drivers/mtd/nand/nand_base.c
Date: Wed, 01 Apr 2015 18:40:17 +0200	[thread overview]
Message-ID: <551C1F71.3040508@free.fr> (raw)

Hello everyone,

In drivers/mtd/nand/nand_base.c there are several instances of
the following code:

	/*
	 * Apply this short delay always to ensure that we do wait tWB in
	 * any case on any machine.
	 */
	ndelay(100);


Is the intent to spin for 100 nanoseconds?

It seems that, for most platforms, ndelay is defined as:
udelay(DIV_ROUND_UP(x, 1000))

So it will resolve to udelay(1) if I understand correctly?
(I suppose sleeping longer is not a problem.)

However the comment implies that 100 ns are sufficient, right?

So if I override ndelay with a function that sleeps *exactly*
the amount requested, everything should keep working?

The reason I ask is because someone added this comment in my
source tree:

#ifdef CONFIG_TANGOX
	udelay(1); /* needs to make it much longer than tWB */
#else
	ndelay(100);
#endif

Also I have to figure out why the build is not picking up this
definition for ndelay (from include/asm-generic/delay.h)

/* 0x5 is 2**32 / 1000000000 (rounded up) */
#define ndelay(n)							\
	({								\
		if (__builtin_constant_p(n)) {				\
			if ((n) / 20000 >= 1)				\
				__bad_ndelay();				\
			else						\
				__const_udelay((n) * 5ul);		\
		} else {						\
			__ndelay(n);					\
		}							\
	})

Although it seems it should take HZ into account, as the argument
is then multiplied by ticks_per_jiffy (which is FREQ/HZ).

Regards.

             reply	other threads:[~2015-04-01 16:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 16:40 Mason [this message]
2015-04-01 20:52 ` Tiny delays in drivers/mtd/nand/nand_base.c Richard Weinberger

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=551C1F71.3040508@free.fr \
    --to=slash.tmp@free.fr \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.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