Received: by 10.223.164.202 with SMTP id h10csp2220619wrb; Thu, 16 Nov 2017 11:19:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMaptMQiCOR9WDIinMlP4P3N7D0rloNEhF3Vsd4/yAOnddqEdWVcLma6If5cir5PdL6Dhhrh X-Received: by 10.84.211.105 with SMTP id b96mr2613292pli.86.1510859973540; Thu, 16 Nov 2017 11:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510859973; cv=none; d=google.com; s=arc-20160816; b=ka471tr5bosSbNQxApXLyWp+bQfqa2a4nsx+DgOpA2m6qc/nwZNKvcP6iZJ2rDbLvz acb1Z05CJrhc48M/MX5MMaAP8Gsk17ufiMNlxgfg2Tey8XB/QpAy6pUchb04GW1U373R zIGrBh5dk7G0OgJV6XzyqARhWrw/kM1S4AnZU7tlHqsQUZR/5CV1B5Kv5DGwlzhMZsxf pCmLPmyxZEyg7eo36A5Sv4YKg4MOsvVSQ1shA0//cDVki4Bv5b1RA+bVbX+38uuTnP2P 6zsIzZK9vp9CrWjYG73MbY8E2eLFAFpDup1/6sAaQDsqqu7aA0EpgE6/N0Pg72g7/6oo 94mA== 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=LaqDgDy3xPUAzxbQtd+G4gRE7//u4K+pvvl48U31Ah8=; b=yugYPbpRiFgMkKYJpuHxLJHmphJw4kWFWCO375b5cLNXvgNYqlQK6vuJ5f1IzZpgMU PT9Mr+GfQQkJ6zWEqcxY06mudTCkWq/hb3r5IjEmC2hePOdYIt0gif9nLW9U/AQP49SW 9WDiz3I8uE+nDX38ZhfwrBr9BY35gFQuZGhOQQJkN51jLolNvQuuhY2capa6qluUAYqs WqSlYYknRtb+H10dIbLOrdzGaHZu1Yx1qOJszOMpVydm5kxMOHgiBndgc81CHKVzCuMm Kh9jtf4DxTRVVyJbJKBgod0oInTdDKb4LqM5DD84e485INhlGz7wdpE7Qla+hPjL6vee tzTA== 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 a2si1362796plt.229.2017.11.16.11.19.19; Thu, 16 Nov 2017 11:19:33 -0800 (PST) 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 S935782AbdKPPrt (ORCPT + 91 others); Thu, 16 Nov 2017 10:47:49 -0500 Received: from us-smtp-delivery-107.mimecast.com ([216.205.24.107]:49522 "EHLO us-smtp-delivery-107.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933811AbdKPPrn (ORCPT ); Thu, 16 Nov 2017 10:47:43 -0500 Received: from CPH-EX1.SDESIGNS.COM (195-215-56-170-static.dk.customer.tdc.net [195.215.56.170]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-123-Hf6AUfRsPAKezMpCLOH86w-1; Thu, 16 Nov 2017 10:47:40 -0500 X-MC-Unique: Hf6AUfRsPAKezMpCLOH86w-1 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 16 Nov 2017 16:47:35 +0100 Subject: Re: [RFC] Improving udelay/ndelay on platforms where that is possible To: Russell King - ARM Linux CC: Linus Torvalds , Alan Cox , LKML , Linux ARM , Steven Rostedt , Ingo Molnar , Thomas Gleixner , "Peter Zijlstra" , John Stultz , Douglas Anderson , Nicolas Pitre , Mark Rutland , Will Deacon , Jonathan Austin , Arnd Bergmann , Kevin Hilman , Michael Turquette , Stephen Boyd , "Boris Brezillon" , Thibaud Cornic , Mason References: <20171101175325.2557ce85@alans-desktop> <4b707ce0-6067-ab36-e167-1acf348d26bf@free.fr> <11393e07-b042-180c-3bcd-484bf51eada6@sigmadesigns.com> <20171115131351.GE31757@n2100.armlinux.org.uk> <1fa81694-7bd2-564b-e5b9-ae53b9ea6620@sigmadesigns.com> <20171116153625.GJ31757@n2100.armlinux.org.uk> From: Marc Gonzalez Message-ID: <9a4cfa9d-3940-b7f2-5a4d-59e89af85bb7@sigmadesigns.com> Date: Thu, 16 Nov 2017 16:47:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: <20171116153625.GJ31757@n2100.armlinux.org.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [172.27.0.114] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 implementation is. Making one >>> implementation conform to your ideas while leaving the other >>> implementations with other expectations is a recipe for bugs. >>> >>> If you really want to do this, fix the loops_per_jiffy implementation >>> as well so that the consistency is maintained. >> >> Hello Russell, >> >> It seems to me that, when using DFS, there's a serious issue with loop-based >> delays. (IIRC, it was you who pointed this out a few years ago.) >> >> If I'm reading arch/arm/kernel/smp.c correctly, loops_per_jiffy is scaled >> when the frequency changes. >> >> But arch/arm/lib/delay-loop.S starts by loading the current value of >> loops_per_jiffy, computes the number of times to loop, and then loops. >> If the frequency increases when the core is in __loop_delay, the >> delay will be much shorter than requested. >> >> Is this a correct assessment of the situation? > > Absolutely correct, and it's something that people are aware of, and > have already catered for while writing their drivers. In their cpufreq driver? In "real" device drivers that happen to use delays? On my system, the CPU frequency may ramp up from 120 MHz to 1.2 GHz. If the frequency increases at the beginning of __loop_delay, udelay(100) would spin only 10 microseconds. This is likely to cause issues in any driver using udelay. How does one cater for that? Regards. From 1584251322874761311@xxx Thu Nov 16 19:16:37 +0000 2017 X-GM-THRID: 1582790467810046578 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread