linux-mips
[Top] [All Lists]

Re: possible overflow in __udelay

To: linux-mips@linux-mips.org
Subject: Re: possible overflow in __udelay
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Wed, 07 Jul 2004 23:57:23 +0900 (JST)
In-reply-to: <20040701.211456.59461492.anemo@mba.ocn.ne.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20040701.211456.59461492.anemo@mba.ocn.ne.jp>
Sender: linux-mips-bounce@linux-mips.org
>>>>> On Thu, 01 Jul 2004 21:14:56 +0900 (JST), Atsushi Nemoto 
>>>>> <anemo@mba.ocn.ne.jp> said:

anemo> Current __udelay implementation will cause internal overflow on
anemo> the first multiplication.

anemo> Basically, the multiplication is:

anemo> X = usecs * 2**64 / (100000 / HZ)

anemo> And maximum input usecs value is 5000 (MAX_UDELAY_MS * 1000).

anemo> If usecs == 5000 and HZ == 1000, X is 5 * 2**64.  Of course
anemo> this can not be held in 64bit variable.

anemo> How should we avoid the overflow?

anemo> ....

Don't you really have any comments?

I believe, for example, mdelay(10) does not work properly on most MIPS
ports (except for DECSTATION and JAZZ which have smaller HZ value).

---
Atsushi Nemoto

<Prev in Thread] Current Thread [Next in Thread>