From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Thu, 04 Jul 2013 00:48:44 +0200 Subject: [U-Boot] [PATCH v4 1/1] NET: Improve TFTP booting performance when CONFIG_USB_KEYBOARD In-Reply-To: <51D45F4D.2010908@wwwdotorg.org> References: <1372847667-31928-1-git-send-email-jilin@nvidia.com> <20130703112023.6172D380A2C@gemini.denx.de> <51D45F4D.2010908@wwwdotorg.org> Message-ID: <20130703224844.AACB2380E6A@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Stephen, In message <51D45F4D.2010908@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: wd at denx.de Accident: A condition in which presence of mind is good, but absence of body is better.