From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guo Ren Subject: Re: [PATCH V9 13/21] csky: Library functions Date: Thu, 18 Oct 2018 11:10:24 +0800 Message-ID: <20181018031024.GA15088@guoren-Inspiron-7460> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Arnd Bergmann Cc: Andrew Morton , Daniel Lezcano , David Miller , gregkh , Christoph Hellwig , Marc Zyngier , Mark Rutland , Peter Zijlstra , Rob Herring , Thomas Gleixner , Linux Kernel Mailing List , linux-arch , DTML , Rob Herring , c-sky_gcc_upstream@c-sky.com, linfei_chen@c-sky.com, Mao Han List-Id: devicetree@vger.kernel.org On Wed, Oct 17, 2018 at 05:24:36PM +0200, Arnd Bergmann wrote: > On Tue, Oct 16, 2018 at 5:02 AM Guo Ren wrote: > > > +++ b/arch/csky/lib/delay.c > > @@ -0,0 +1,39 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. > > +#include > > +#include > > +#include > > +#include > > + > > +void __delay(unsigned long loops) > > +{ > > + asm volatile ( > > + "mov r0, r0\n" > > + "1:declt %0\n" > > + "bf 1b" > > + : "=r"(loops) > > + : "0"(loops)); > > +} > > +EXPORT_SYMBOL(__delay); > > + > > +void __const_udelay(unsigned long xloops) > > +{ > > + unsigned long long loops; > > + > > + loops = (unsigned long long)xloops * loops_per_jiffy * HZ; > > + > > + __delay(loops >> 32); > > +} > > +EXPORT_SYMBOL(__const_udelay); > > I can't find any indication we discussed this part before. Can you > explain (in the > changelog and in a reply) if there is a reliable high-resolution clocksource > available in the architecture? If you can read the elapsed time here instead of > using the loops_per_jiffy estimate, that would make this more robust, as > well as speed up the boot. > > If you can't do that in general, that's fine, and you can add my I'll add TODO list here, __delay should use get_cycles() and we didn't implement __udelay() __ndelay() ... We'll improve it next. Best Regards Guo Ren