* [PATCH] mtd: nand: docg4: add udelay(1) to polling loop
@ 2013-04-22 18:23 Mike Dunn
2013-05-16 7:43 ` Artem Bityutskiy
0 siblings, 1 reply; 3+ messages in thread
From: Mike Dunn @ 2013-04-22 18:23 UTC (permalink / raw)
To: linux-mtd; +Cc: Mike Dunn
Add call to udelay(1) in the busy-wait loop that polls the device status
register. This will make the timeout independent of cpu clock rate. This
sloppiness came back to bite me when I increased the cpu clock rate, and
timeouts started occurring during long block erasure operations.
Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
---
drivers/mtd/nand/docg4.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index 18fa448..fd353d2 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -279,6 +279,7 @@ static int poll_status(struct docg4_priv *doc)
timeo = 1000;
do {
+ udelay(1);
cpu_relax();
flash_status = readb(docptr + DOC_FLASHCONTROL);
} while (!(flash_status & DOC_CTRL_FLASHREADY) && --timeo);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: docg4: add udelay(1) to polling loop
2013-04-22 18:23 [PATCH] mtd: nand: docg4: add udelay(1) to polling loop Mike Dunn
@ 2013-05-16 7:43 ` Artem Bityutskiy
2013-05-16 19:49 ` Mike Dunn
0 siblings, 1 reply; 3+ messages in thread
From: Artem Bityutskiy @ 2013-05-16 7:43 UTC (permalink / raw)
To: Mike Dunn; +Cc: linux-mtd
On Mon, 2013-04-22 at 11:23 -0700, Mike Dunn wrote:
> timeo = 1000;
> do {
> + udelay(1);
> cpu_relax();
> flash_status = readb(docptr + DOC_FLASHCONTROL);
> } while (!(flash_status & DOC_CTRL_FLASHREADY) && --timeo);
How about using jiffies instead? Something like:
timeout = jiffies + msecs_to_jiffies(delay);
do {
} while (time_before(jiffies, timeout))
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: docg4: add udelay(1) to polling loop
2013-05-16 7:43 ` Artem Bityutskiy
@ 2013-05-16 19:49 ` Mike Dunn
0 siblings, 0 replies; 3+ messages in thread
From: Mike Dunn @ 2013-05-16 19:49 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
On 05/16/2013 12:43 AM, Artem Bityutskiy wrote:
> On Mon, 2013-04-22 at 11:23 -0700, Mike Dunn wrote:
>> timeo = 1000;
>> do {
>> + udelay(1);
>> cpu_relax();
>> flash_status = readb(docptr + DOC_FLASHCONTROL);
>> } while (!(flash_status & DOC_CTRL_FLASHREADY) && --timeo);
>
> How about using jiffies instead? Something like:
>
> timeout = jiffies + msecs_to_jiffies(delay);
> do {
> } while (time_before(jiffies, timeout))
>
This works too (just tested it). But the reason I did not do this originally is
because the timeout is very short. With udelay(1) and timeo=1000, the timeout
is 1ms (plus processing time), and I think this is well in excess of the actual
time needed by the hardware. Using jiffies and with HZ=100, my minimum timeout
is 10ms. But there's no harm in having an excessive timeout since it's a
busy-wait loop, so your suggestion is probably fine.
Is use of udelay() frowned upon? Will using jiffies cause a problem with a
"tickless" configuration? Hoping to learn something...
Thanks Artem!
Mike
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-16 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 18:23 [PATCH] mtd: nand: docg4: add udelay(1) to polling loop Mike Dunn
2013-05-16 7:43 ` Artem Bityutskiy
2013-05-16 19:49 ` Mike Dunn
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.