Received: by 10.223.164.221 with SMTP id h29csp1220358wrb; Wed, 1 Nov 2017 12:29:54 -0700 (PDT) X-Google-Smtp-Source: ABhQp+THV6YhY0112jfWIrATN6Qow5jmBN0dL7QZT4ZjLwceO6G0k4J9N5iCzakxIbdAfoCWeDHn X-Received: by 10.84.215.157 with SMTP id l29mr616091pli.181.1509564594439; Wed, 01 Nov 2017 12:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509564594; cv=none; d=google.com; s=arc-20160816; b=sWl2RZuDK9nUq8dsiIMmHYNfiiVera2WkwrpK66WHPyrrdth3LhfyFLQnRwKF6jx8p rG8NxzcoqXH9g8VbJiQM9c5CN33DpaQ7hLkmosQjJYjdZxcJ0hj3AtUx0k0CQk+6s6o7 xTS4QlzoU2nvm5XoeDouiiLkf7ZRLu+BqLa7vxZIp+xzamqsiS6ZUDYfIRVYJ5fmmXmH IH8X81YV4WDNMmkwbTDFpe7YI3iuKUXGi8sqK8JnAtdz8qYlCpS0OYkxPt3AzwkMg6CB 4v6S75DVdXx7x540X9Ex9uCKPGd7xJMZ+gZ+OmopImjA/59n28YdWAPJMsi6pXOx9jBM JT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:arc-authentication-results; bh=1zw4n98W/WJyrk6lq0bVU2/Jam9sH3z74Geb3zJzJlk=; b=KpQA2RLHPrLq3nHG18v+uf1C5PBODi/plPI2jpTumqf0QyNhRyUO0ZBJJIuTk7AyHS AaA7Do0fQBH2v2Q7o/FRWpU0eCm0dYPPXXz4zvUTfDIWbDbfAZwRFNlZrHW63Kjeggs1 bSHDIkTR27EbwlHaS/ABo7kIJ76zhIuwS+OIWKdv6DmEFXEKeUO0MlpGkCYbRjuUqXQp jEU8sxrbiQW28c2rolHDY8rE4lAP84ok44TPqeK0HnqckTzvIMMONNlge8QcKbL/cR0v wjpIHVfVgAG4jtz7YlugdBWab4csna+RRIV9Ua2ySc6sA7vq0Qk3ECHnKgsE8kHYrWAb pvVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si370954pli.743.2017.11.01.12.29.41; Wed, 01 Nov 2017 12:29:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755255AbdKAT21 (ORCPT + 99 others); Wed, 1 Nov 2017 15:28:27 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]:34786 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755245AbdKAT2Y (ORCPT ); Wed, 1 Nov 2017 15:28:24 -0400 Received: from [192.168.0.66] (unknown [88.191.210.51]) by smtp2-g21.free.fr (Postfix) with ESMTP id EF7802003DF; Wed, 1 Nov 2017 20:28:20 +0100 (CET) Subject: Re: [RFC] Improving udelay/ndelay on platforms where that is possible To: Russell King - ARM Linux Cc: Doug Anderson , Linus Torvalds , Mark Rutland , Jonathan Austin , Arnd Bergmann , Peter Zijlstra , Will Deacon , Michael Turquette , Nicolas Pitre , Stephen Boyd , Steven Rostedt , LKML , Kevin Hilman , John Stultz , Thomas Gleixner , Ingo Molnar , Linux ARM , Mason References: <20171031165629.GF9463@n2100.armlinux.org.uk> <20171101092618.GN9463@n2100.armlinux.org.uk> From: Marc Gonzalez Message-ID: <475b9543-cc97-41b3-2924-0724fddee392@free.fr> Date: Wed, 1 Nov 2017 20:28:18 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: <20171101092618.GN9463@n2100.armlinux.org.uk> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 particularly well on that >>> platform, I think we should merge them. But ... >> >> If I'm reading this all correctly, this sounds like you'd be willing >> to merge . This makes >> udelay() guaranteed not to underrun on arm32 platforms. > > That's a mis-representation again. It stops a timer-based udelay() > possibly underrunning by one tick if we are close to the start of > a count increment. However, it does nothing for the loops_per_jiffy > udelay(), which can still underrun. It is correct that improving the clock-based implementation does strictly nothing for the loop-based implementation. Is it possible to derive a higher bound on the amount of under-run when using the loop-based delay on arm32? > My argument against merging that patch is that with it merged, we get > (as you say) a udelay() that doesn't underrun _when using a timer_ > but when we end up using the loops_per_jiffy udelay(), we're back to > the old problem. > > My opinion is that's bad, because it encourages people to write drivers > that rely on udelay() having "good" behaviour, which it is not guaranteed > to have. So, they'll specify a delay period of exactly what they want, > and their drivers will then fail when running on systems that aren't > using a timer-based udelay(). > > If we want udelay() to have this behaviour, it needs to _always_ have > this behaviour irrespective of the implementation. So that means > the loops_per_jiffy version also needs to be fixed in the same way, > which IMHO is impossible. Let's say some piece of HW absolutely, positively, unequivocally, uncompromisingly, requires a strict minimum of 10 microseconds elapsing between operations A and B. You say a driver writer must not write udelay(10); They have to take into account the possibility of under-delay. How much additional delay should they add? 10%? 20%? 50%? A percentage + a fixed quantity? If there is an actual rule, then it could be incorporated in the loop-based implementation? If it is impossible to say (as Linus hinted for some platforms) then this means there is no way to guarantee a minimal delay? Regards. From 1582892508301737742@xxx Wed Nov 01 19:18:50 +0000 2017 X-GM-THRID: 1582790467810046578 X-Gmail-Labels: Inbox,Category Forums