From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH 02 of 10] arm: implement udelay() Date: Mon, 27 Feb 2012 19:19:28 +0000 Message-ID: <20120227191928.GA98737@ocelot.phlegethon.org> References: <4F468D9A.3050000@cantab.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <4F468D9A.3050000@cantab.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: xen-devel@lists.xensource.com, Stefano Stabellini , Ian Campbell List-Id: xen-devel@lists.xenproject.org At 19:03 +0000 on 23 Feb (1330023834), David Vrabel wrote: > On 23/02/12 17:40, Tim Deegan wrote: > > arm: implement udelay() > > > > Signed-off-by: Tim Deegan > > > [...] > > diff -r 4a7c14209131 -r ec051056db2b xen/arch/arm/time.c > > --- a/xen/arch/arm/time.c Thu Feb 23 17:39:59 2012 +0000 > > +++ b/xen/arch/arm/time.c Thu Feb 23 17:39:59 2012 +0000 > > @@ -171,6 +171,16 @@ void __cpuinit init_timer_interrupt(void > > request_irq(30, timer_interrupt, 0, "phytimer", NULL); > > } > > > > +/* Wait a set number of microseconds */ > > +void udelay(unsigned long usecs) > > +{ > > + s_time_t deadline = get_s_time() + 1000 * (s_time_t) usecs; > > + do { > > + dsb(); > > + isb(); > > What are these barriers for? To make sure the CPU doesn't hoist any instructions past the wait loop. :) They don't really have to be inside the loop body; I can change that if you like. Tim.