Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-12-07 Thread Pavel Machek
> On Wed, Nov 15, 2017 at 01:51:54PM +0100, Marc Gonzalez wrote: > > On 01/11/2017 20:38, Marc Gonzalez wrote: > > > > > OK, I'll just send my patch, and then crawl back under my rock. > > > > Linus, > > > > As promised, the patch is provided below. And as promised, I will > > no longer bring th

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-12-07 Thread Pavel Machek
Hi! > On Wed, Nov 1, 2017 at 2:26 AM, Russell King - ARM Linux > wrote: > > On Tue, Oct 31, 2017 at 05:23:19PM -0700, Doug Anderson wrote: > >> Hi, > >> > >> On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds > >> wrote: > >> > So I'm very much open to udelay improvements, and if somebody sends >

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-20 Thread Russell King - ARM Linux
On Mon, Nov 20, 2017 at 09:38:46AM -0800, Doug Anderson wrote: > Hi, > > On Thu, Nov 16, 2017 at 3:22 PM, Russell King - ARM Linux > wrote: > > On Thu, Nov 16, 2017 at 02:15:02PM -0800, Doug Anderson wrote: > >> Hi, > >> > >> On Thu, Nov 16, 2017 at 1:05 PM, Marc Gonzalez > >> wrote: > >> > On 1

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-20 Thread Doug Anderson
Hi, On Thu, Nov 16, 2017 at 3:22 PM, Russell King - ARM Linux wrote: > On Thu, Nov 16, 2017 at 02:15:02PM -0800, Doug Anderson wrote: >> Hi, >> >> On Thu, Nov 16, 2017 at 1:05 PM, Marc Gonzalez >> wrote: >> > On 16/11/2017 18:05, Russell King - ARM Linux wrote: >> > >> >> On Thu, Nov 16, 2017 at

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Russell King - ARM Linux
On Thu, Nov 16, 2017 at 02:15:02PM -0800, Doug Anderson wrote: > Hi, > > On Thu, Nov 16, 2017 at 1:05 PM, Marc Gonzalez > wrote: > > On 16/11/2017 18:05, Russell King - ARM Linux wrote: > > > >> On Thu, Nov 16, 2017 at 05:42:36PM +0100, Marc Gonzalez wrote: > >> > >>> Requesting 100 µs and spinni

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Doug Anderson
Hi, On Thu, Nov 16, 2017 at 1:05 PM, Marc Gonzalez wrote: > On 16/11/2017 18:05, Russell King - ARM Linux wrote: > >> On Thu, Nov 16, 2017 at 05:42:36PM +0100, Marc Gonzalez wrote: >> >>> Requesting 100 µs and spinning only 25 µs is still a problem, >>> don't you agree? >> >> Which is why, as I'v

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 16/11/2017 18:05, Russell King - ARM Linux wrote: > On Thu, Nov 16, 2017 at 05:42:36PM +0100, Marc Gonzalez wrote: > >> Requesting 100 µs and spinning only 25 µs is still a problem, >> don't you agree? > > Which is why, as I've said *many* times already, that drivers are written > with leaway

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Russell King - ARM Linux
On Thu, Nov 16, 2017 at 05:42:36PM +0100, Marc Gonzalez wrote: > On 16/11/2017 17:32, Russell King - ARM Linux wrote: > > On Thu, Nov 16, 2017 at 05:26:32PM +0100, Marc Gonzalez wrote: > >> On 16/11/2017 17:08, Nicolas Pitre wrote: > >> > >>> On Thu, 16 Nov 2017, Marc Gonzalez wrote: > >>> > O

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Nicolas Pitre
On Thu, 16 Nov 2017, Marc Gonzalez wrote: > On 16/11/2017 17:47, Nicolas Pitre wrote: > > > Look at cpufreq_callback() in arch/arm/kernel/smp.c. > > Are you pointing at the scaling of loops_per_jiffy done in that function? > > As I wrote earlier: > > If I'm reading arch/arm/kernel/smp.c correc

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 16/11/2017 17:47, Nicolas Pitre wrote: > Look at cpufreq_callback() in arch/arm/kernel/smp.c. Are you pointing at the scaling of loops_per_jiffy done in that function? As I wrote earlier: If I'm reading arch/arm/kernel/smp.c correctly, loops_per_jiffy is scaled when the frequency changes. B

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Nicolas Pitre
On Thu, 16 Nov 2017, Marc Gonzalez wrote: > On 16/11/2017 17:08, Nicolas Pitre wrote: > > > On Thu, 16 Nov 2017, Marc Gonzalez wrote: > > > >> On 16/11/2017 16:36, Russell King - ARM Linux wrote: > >>> On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: > On 15/11/2017 14:13, Rus

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 16/11/2017 17:32, Russell King - ARM Linux wrote: > On Thu, Nov 16, 2017 at 05:26:32PM +0100, Marc Gonzalez wrote: >> On 16/11/2017 17:08, Nicolas Pitre wrote: >> >>> On Thu, 16 Nov 2017, Marc Gonzalez wrote: >>> On 16/11/2017 16:36, Russell King - ARM Linux wrote: > On Thu, Nov 16, 201

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Russell King - ARM Linux
On Thu, Nov 16, 2017 at 05:26:32PM +0100, Marc Gonzalez wrote: > On 16/11/2017 17:08, Nicolas Pitre wrote: > > > On Thu, 16 Nov 2017, Marc Gonzalez wrote: > > > >> On 16/11/2017 16:36, Russell King - ARM Linux wrote: > >>> On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: > On 1

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 16/11/2017 17:08, Nicolas Pitre wrote: > On Thu, 16 Nov 2017, Marc Gonzalez wrote: > >> On 16/11/2017 16:36, Russell King - ARM Linux wrote: >>> On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: On 15/11/2017 14:13, Russell King - ARM Linux wrote: > udelay() needs to

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Nicolas Pitre
On Thu, 16 Nov 2017, Marc Gonzalez wrote: > On 16/11/2017 16:36, Russell King - ARM Linux wrote: > > On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: > >> On 15/11/2017 14:13, Russell King - ARM Linux wrote: > >> > >>> udelay() needs to offer a consistent interface so that drivers kn

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 16/11/2017 16:36, Russell King - ARM Linux wrote: > On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: >> On 15/11/2017 14:13, Russell King - ARM Linux wrote: >> >>> udelay() needs to offer a consistent interface so that drivers know >>> what to expect no matter what the implementati

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Russell King - ARM Linux
On Thu, Nov 16, 2017 at 04:26:51PM +0100, Marc Gonzalez wrote: > On 15/11/2017 14:13, Russell King - ARM Linux wrote: > > > udelay() needs to offer a consistent interface so that drivers know > > what to expect no matter what the implementation is. Making one > > implementation conform to your id

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-16 Thread Marc Gonzalez
On 15/11/2017 14:13, Russell King - ARM Linux wrote: > udelay() needs to offer a consistent interface so that drivers know > what to expect no matter what the implementation is. Making one > implementation conform to your ideas while leaving the other > implementations with other expectations is

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-15 Thread Doug Anderson
Hi, On Wed, Nov 15, 2017 at 4:51 AM, Marc Gonzalez wrote: > On 01/11/2017 20:38, Marc Gonzalez wrote: > >> OK, I'll just send my patch, and then crawl back under my rock. > > Linus, > > As promised, the patch is provided below. And as promised, I will > no longer bring this up on LKML. > > FWIW,

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-15 Thread Russell King - ARM Linux
On Wed, Nov 15, 2017 at 01:51:54PM +0100, Marc Gonzalez wrote: > On 01/11/2017 20:38, Marc Gonzalez wrote: > > > OK, I'll just send my patch, and then crawl back under my rock. > > Linus, > > As promised, the patch is provided below. And as promised, I will > no longer bring this up on LKML. >

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-15 Thread Marc Gonzalez
On 01/11/2017 20:38, Marc Gonzalez wrote: > OK, I'll just send my patch, and then crawl back under my rock. Linus, As promised, the patch is provided below. And as promised, I will no longer bring this up on LKML. FWIW, I have checked that the computed value matches the expected value for all H

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-02 Thread Boris Brezillon
On Wed, 1 Nov 2017 21:48:22 +0200 Baruch Siach wrote: > Hi Marc, > > On Wed, Nov 01, 2017 at 08:03:20PM +0100, Marc Gonzalez wrote: > > On 01/11/2017 18:53, Alan Cox wrote: > > > For that matter given the bad blocks don't randomly change why not cache > > > them ? > > > > That's a good que

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Russell King - ARM Linux
On Wed, Nov 01, 2017 at 08:28:18PM +0100, Marc Gonzalez wrote: > On 01/11/2017 10:26, Russell King - ARM Linux wrote: > > > On Tue, Oct 31, 2017 at 05:23:19PM -0700, Doug Anderson wrote: > > > >> On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds wrote: > >> > >>> So I'm very much open to udelay imp

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Baruch Siach
Hi Marc, On Wed, Nov 01, 2017 at 08:03:20PM +0100, Marc Gonzalez wrote: > On 01/11/2017 18:53, Alan Cox wrote: > > For that matter given the bad blocks don't randomly change why not cache > > them ? > > That's a good question, I'll ask the NAND framework maintainer. > Store them where, by the wa

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Thomas Gleixner
On Wed, 1 Nov 2017, Marc Gonzalez wrote: > On 01/11/2017 18:53, Alan Cox wrote: > > > On Tue, 31 Oct 2017 17:15:34 +0100 > > > >> Therefore, users are accustomed to having delays be longer (within a > >> reasonable margin). > >> However, very few users would expect delays to be *shorter* than re

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Marc Gonzalez
On 01/11/2017 20:09, Linus Torvalds wrote: > On Wed, Nov 1, 2017 at 12:03 PM, Marc Gonzalez wrote: > >> By default, ndelay is implemented in terms of udelay. > > That's very much *NOT* the case. > > Yes, there is a *fallback* for when somebody doesn't do ndelay() at > all, but that doesn't make

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Alan Cox
> > serialized link. Writes get delayed, they can bunch together, busses do > > posting and queueing. > > Are you talking about the actual delay operation, or the pokes around it? All of it. A write from the CPU except on the lowest end ones isn't neccessarily going to occur in strict sequentia

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Marc Gonzalez
On 01/11/2017 10:26, Russell King - ARM Linux wrote: > On Tue, Oct 31, 2017 at 05:23:19PM -0700, Doug Anderson wrote: > >> On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds wrote: >> >>> So I'm very much open to udelay improvements, and if somebody sends >>> patches for particular platforms to do p

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Linus Torvalds
On Wed, Nov 1, 2017 at 12:09 PM, Linus Torvalds wrote: > > Yes, there is a *fallback* for when somebody doesn't do ndelay() at > all, but that doesn't make it the default. > > It's just a "the architecture didn't implement ndelay at all, we'll > work around it". Side note: I will continue to cla

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Linus Torvalds
On Wed, Nov 1, 2017 at 12:03 PM, Marc Gonzalez wrote: > > By default, ndelay is implemented in terms of udelay. That's very much *NOT* the case. Yes, there is a *fallback* for when somebody doesn't do ndelay() at all, but that doesn't make it the default. It's just a "the architecture didn't im

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Marc Gonzalez
On 01/11/2017 18:53, Alan Cox wrote: > On Tue, 31 Oct 2017 17:15:34 +0100 > >> Therefore, users are accustomed to having delays be longer (within a >> reasonable margin). >> However, very few users would expect delays to be *shorter* than requested. > > If your udelay can be under by 10% then ju

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Alan Cox
On Tue, 31 Oct 2017 17:15:34 +0100 > Therefore, users are accustomed to having delays be longer (within a > reasonable margin). > However, very few users would expect delays to be *shorter* than requested. If your udelay can be under by 10% then just bump the number by 10%. However at that level

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Doug Anderson
Hi, On Wed, Nov 1, 2017 at 2:26 AM, Russell King - ARM Linux wrote: > On Tue, Oct 31, 2017 at 05:23:19PM -0700, Doug Anderson wrote: >> Hi, >> >> On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds >> wrote: >> > So I'm very much open to udelay improvements, and if somebody sends >> > patches for p

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-11-01 Thread Russell King - ARM Linux
On Tue, Oct 31, 2017 at 05:23:19PM -0700, Doug Anderson wrote: > Hi, > > On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds > wrote: > > So I'm very much open to udelay improvements, and if somebody sends > > patches for particular platforms to do particularly well on that > > platform, I think we

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Doug Anderson
Hi, On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds wrote: > So I'm very much open to udelay improvements, and if somebody sends > patches for particular platforms to do particularly well on that > platform, I think we should merge them. But ... If I'm reading this all correctly, this sounds li

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Linus Torvalds
On Tue, Oct 31, 2017 at 10:45 AM, Linus Torvalds wrote: > > So I'm very much open to udelay improvements, and if somebody sends > patches for particular platforms to do particularly well on that > platform, I think we should merge them. But ... Side note: this is obviously a negative feedback cir

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Linus Torvalds
On Tue, Oct 31, 2017 at 9:56 AM, Russell King - ARM Linux wrote: > > Marc is stating something that's incorrect there. On ARM32, we don't > have a TSC, and we aren't guaranteed to have a timer usable for delays. > Where there is a suitable timer, it can be used for delays. > > However, where ther

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Russell King - ARM Linux
On Tue, Oct 31, 2017 at 09:44:20AM -0700, Linus Torvalds wrote: > On Tue, Oct 31, 2017 at 9:15 AM, Marc Gonzalez > wrote: > > > > On arm32, it is possible to set up udelay() to be clock-based. > > I'm not sure why this is discussed as some kind of generic problem. Hi Linus, Marc is stating some

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Russell King - ARM Linux
On Tue, Oct 31, 2017 at 05:15:34PM +0100, Marc Gonzalez wrote: > I am writing to you directly because Russell has bluntly stated (paraphrased) > "Send your patches to Linus; it's his kernel, and he has the final say." which > is his diplomatic way of telling me to fsck off. ... after I've already

Re: [RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Linus Torvalds
On Tue, Oct 31, 2017 at 9:15 AM, Marc Gonzalez wrote: > > On arm32, it is possible to set up udelay() to be clock-based. I'm not sure why this is discussed as some kind of generic problem. Just do what x86-64 already does. We use the TSC, and ndelay() does the right thing too. I've not checked

[RFC] Improving udelay/ndelay on platforms where that is possible

2017-10-31 Thread Marc Gonzalez
Hello BDFL, I am writing to you directly because Russell has bluntly stated (paraphrased) "Send your patches to Linus; it's his kernel, and he has the final say." which is his diplomatic way of telling me to fsck off. Basically, I want to improve the accuracy of clock-based delays, in order to im