From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Andreas_Bie=DFmann?= Date: Mon, 24 Jan 2011 13:58:29 +0100 Subject: [U-Boot] [RFC] ARM timing code refactoring In-Reply-To: <4D3D695A.6060006@free.fr> References: <4D3AAF63.1030600@free.fr> <20110122191928.49E141365DB@gemini.denx.de> <4D3B3B5C.2060205@free.fr> <20110122212601.9C8A2B187@gemini.denx.de> <4D3B5171.7090700@emk-elektronik.de> <20110123101217.E31DFB335@gemini.denx.de> <4D3C0271.4070306@emk-elektronik.de> <20110123162312.CDEDE1365DB@gemini.denx.de> <4D3C77BC.50006@emk-elektronik.de> <20110123193502.3F2484B6@gemini.denx.de> <4D3C96A9.7030402@free.fr> <4D3C9BFC.1010907@emk-elektronik.de> <20110123225758.222691365DB@gemini.denx.de> <4D3CD8FE.4040006@comcast.net> <4D3D2942.4060600@free.fr> <5A727AB5-C1C6-46D3-8C0B-A868EC6B1E7A@googlemail.com> <4D3D695A.6060006@free.fr> Message-ID: <4D3D7775.6080108@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Albert, Am 24.01.2011 12:58, schrieb Albert ARIBAUD: > Hi Andreas, > > Le 24/01/2011 09:25, Andreas Bie?mann a ?crit : > >>> That's where I come back to one point of my proposal: if we can get a >>> general framework for get_timer() to return a 64-bit free-running tick >>> value, then we might not need a ms-based get_time() at all, because we >>> could use get_timer() as well for ms timings, provided we can convert >>> our timeout from ms to ticks, i.e. >>> >>> /* let's wait 200 milliseconds */ >>> /* Timing loop uses ticks: convert 200 ms to 'timeout' ticks */ >>> timeout = ms_to_ticks(200); >>> u32 start = get_timer(); /* start time, in ticks */ >>> do { >>> ... >>> } while ( (get_timer() -start)< timeout); >> >> You may think about the following change to this proposal: >> >> /* lets wait 200 ms */ >> /* get the end point of our timeout in ticks */ >> u64 timeout_end = get_timer() + ms_to_ticks(200); >> do { >> ... >> } while ( get_timer()< timeout_end); > > The problem here is that in the loop exit condition you replace a > difference between two unsigned times (which always yields the correct > duration) with a comparison of two dates (which does not). Ok, I got your point. regards Andreas Bie?mann