Dear Stephen, In message <51d45f4d.2010...@wwwdotorg.org> you wrote: > > > get_timer() is used by a number of network related services. For > > information, just grep for it in the net/ and drivers/net/ > > directories. The "get_timer(0)" used in your code resets a global > > resource, and has thus the potential of messing up a number of > > timeouts running elsewhere in the network code. I wonder to which > > extend this has actually been considered (and tested) ? > > I recall you mentioning this before, but can you expand on this a bit > please? > > For the two platforms I'm familiar with (Tegra and BCM2835), the > implementation of get_timer() is simply: > > unlong get_timer(ulong base) > { > ulong time = read_hw_register() > time -= base; > return time; > } > > There's no global state involved. Is this implementation of get_timer() > wrong somehow? I'm having a hard time envisaging what kind of global > state it's supposed to maintain.
It appears you are (basically) right. Eventually I remember an old implementation that has been fixed since. I checked all implementations I could find (all 102 of them) and they all behave as you showed in your example, i. e. harmless. An exception is "arch/arm/cpu/sa1100/timer.c" which does not respect the "base" argument at all, i. e. which is broken. > I always thought that every user of get_timer() was supposed to do > something like: > > ulong base = get_timer(0); > ... work to be timed > ulong time_diff = get_timer(base); > > in other words, every user maintains their own base variable, and hence > get_timer(0) doesn't affect any other users. Yes, you are right. Sorry for causing confusion here. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Accident: A condition in which presence of mind is good, but absence of body is better. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot