[Top] [All Lists]

Re: about udelay in mips

To: loody <>
Subject: Re: about udelay in mips
From: wu zhangjin <>
Date: Fri, 14 Jan 2011 13:31:53 +0800
Cc: Linux MIPS Mailing List <>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=K3Z7DEtAVk9nWhTFSVDm7wSlNfdkKG2by7iWIcrTTic=; b=m6qvQTrV7Lp5oAmq9W5BLyUAr29afEAchCr29iuBFTlOsDbll6qD8+shS/hvoPV7Uw CnUiut9wkAEtpw3nmhSTWOwB8Tvr16KCsFNH4S9m6lzmAISJtujfrmzICjn146jwdfYB xg3budnhXigs0nR4uhv5RMMEtBDZ3QwGmECx0=
Domainkey-signature: a=rsa-sha1; c=nofws;; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Kr293CIei+6xzC4e1XLPDaK2uumzvcSK7GC5PFv5V6v1d62vPQNdOCBnGyBXCETy3k BZ4Oyc05bZjGC7KyRrE8pI/eC0I0Z1VvB/3VIZWzhbjckq9+SMr+GFhtE/KJPlzrRPvN TEJ3lPxaJ1LE9uePZzjQecv4v5RMRJvr5FezI=
In-reply-to: <>
Original-recipient: rfc822;
References: <>
On Thu, Jan 13, 2011 at 6:02 PM, loody <> wrote:
> hi all:
> If i trace source in the correct place, I found udelay(100) is
> implemented as a loop which decrease 1 per iteration until the count,
> 100, as 0.
> What makes me confused is since the speed of cpus are different and
> that will make udelay not precise on different platform, right?

Yeah, it may be not precise, so, some processors, like Cavium octeon
have added their own timestamp register based delay functions, please
refer to:


The delay_tsc() for X86 defined in arch/x86/lib/delay.c is similar.

But both of them are 64bit timestamp registers.

We can also apply similar method to add the precise delays for the
other CPUs, but we may need to take extra notice:

1. If the CPU only provides 32bit timestamp registers(e.g R4K MIPS),
overflow should be considered.
2. If the CPU support dynamic CPU frequency and the frequency of the
timestamp binds to the CPU's frequency, the scaled down timestamp
should be converted to the real timestamp.

Wu Zhangjin

> --
> Regards,
> miloody

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