Received: by 10.223.164.202 with SMTP id h10csp2234013wrb; Thu, 16 Nov 2017 11:34:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMZr2m1G2i/BpWHxNDyuiR/gjODbbFnH7WQr2dItWXh6ppp4Zj3G+FPaT321AbJaw9oyY+g3 X-Received: by 10.99.97.66 with SMTP id v63mr2609538pgb.84.1510860847908; Thu, 16 Nov 2017 11:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510860847; cv=none; d=google.com; s=arc-20160816; b=0v2Ok+bHHudRTZzFLqoees2HrD0uYcGyCo3Xev49DadmpOt0SzWPb8xJnkIhbCvN2w M9qz5iMCfmjrUsPt57Y/68cVWebdGrUQQ3J6We4PG84mU2RCdfQ4MiQEvB2czJJAOoab sFkDMAg+g0HnGg+hsfR3+IOjy4pw5/NWkLwWb5PkdvskqTIa0DIc8SpNi3bSjggZNVBQ xUGJZZSTY1OnWnwHevx+vvkJ2bBxIed+wnYv0GXgLJDj4t7cfMslIPJios2oBIo5vj9m 8ARHRtj01PxyOnTtu7QfNAuMQON2lrWXk92ZkYQt1Yp/pCZlfT5bKx/eAIk9AvIunFo/ 4r5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=7YaeVL1fEw74ec9995epeuqJ+5ou+whlQcA87d3jbrA=; b=lwRsdj28nQpHkhoZo997tBpTKF4+2GjCs31u/WkKl0URgw0248Cb1UnuS2/2mr2eMB 5DcSut2DORHe3+pT1czHylkCD51xNHV1xgB14lQXEUmcCuzDPHZbdPAay57VH19ON8GN PAJ4NxfKN6rzg0O5D9KYs+0moDz3F/WEnSuBFN0pw1lNTywC8QxgIEDVLtU8ZkhtQ2ND WQujKKsmvLePyGhFFlVov4eZXKZrO3W1ekMpzcUXEri2ccVv0pQAr0Nj/5DUp6o+cXiX eOHew7nh/cFk32EQbP+zOgkaBLb46q0zFl/1y9c8Rg7VlOjBNbOTAS0/XJZHbShc7Gfk AyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a/LV4pOB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q77si1527846pfa.15.2017.11.16.11.33.55; Thu, 16 Nov 2017 11:34:07 -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; dkim=pass header.i=@linaro.org header.s=google header.b=a/LV4pOB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759998AbdKPQIU (ORCPT + 91 others); Thu, 16 Nov 2017 11:08:20 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:46724 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754765AbdKPQIO (ORCPT ); Thu, 16 Nov 2017 11:08:14 -0500 Received: by mail-qt0-f194.google.com with SMTP id a19so4272444qtb.3 for ; Thu, 16 Nov 2017 08:08:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=7YaeVL1fEw74ec9995epeuqJ+5ou+whlQcA87d3jbrA=; b=a/LV4pOBcC3GgjTbrDbFCWqMWSvi0btVLZ8O82gf0njeQQ8Lon9vYy9vwktOteXbtB inGTxLO6Z1AU6jDVXWN9hru00dxbKBJWxsmHQt7QmxuEFRMwo1TA5oVkLhFZhXCIbAOY Ios7USmsec3VZvis00zcHJQSNMuSzmJp5Ro+E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=7YaeVL1fEw74ec9995epeuqJ+5ou+whlQcA87d3jbrA=; b=NTvXbwHs5j63rUH2dhSK3HP74R1OJDCePZS6PzIsZFYiKucRg5v0NBrsOJoSUuHHTZ xlOa6w89ks5Yp+4ureof9umSgoFQA57Lo7cPnnlT0MDEiPRsrZVWzz6fGxrMEmlNMYy1 HpocfOdFTFiQYG1QTwip230VUm7rHcg37UpLa7KMf2nv2dy3a4Bj55v3SLsZCn8e8WF2 8Ci9ge/UO5HmjTRE+SbQGn8uumDN3JKnvEaO532bd4iqJAQQyoTv7abDT4ycWqMHA6Mm VmvbFeUJlmOaKeWfG3lqpFQEj8ed92yF381Ulte+wZ67bxBfUufAUTeFMF7AmixzFrKE EpwQ== X-Gm-Message-State: AJaThX5eir/lEsg2HjNIaQWRzvAIRaI/tFUmuLzZMtkhoSL5FWRpdvg/ o+82lyddhpWrCWRePZrZTPzTpQ== X-Received: by 10.200.56.72 with SMTP id r8mr3390973qtb.203.1510848493262; Thu, 16 Nov 2017 08:08:13 -0800 (PST) Received: from xanadu.home (modemcable045.234-175-137.mc.videotron.ca. [137.175.234.45]) by smtp.gmail.com with ESMTPSA id k43sm1042473qtc.75.2017.11.16.08.08.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2017 08:08:12 -0800 (PST) Date: Thu, 16 Nov 2017 11:08:11 -0500 (EST) From: Nicolas Pitre To: Marc Gonzalez cc: Russell King - ARM Linux , Linus Torvalds , Alan Cox , LKML , Linux ARM , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , John Stultz , Douglas Anderson , Mark Rutland , Will Deacon , Jonathan Austin , Arnd Bergmann , Kevin Hilman , Michael Turquette , Stephen Boyd , Boris Brezillon , Thibaud Cornic , Mason Subject: Re: [RFC] Improving udelay/ndelay on platforms where that is possible In-Reply-To: <9a4cfa9d-3940-b7f2-5a4d-59e89af85bb7@sigmadesigns.com> Message-ID: 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> <9a4cfa9d-3940-b7f2-5a4d-59e89af85bb7@sigmadesigns.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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? You make sure your delays are based on a stable hardware timer. Most platforms nowdays should have a suitable timer source. Nicolas From 1584251507603297975@xxx Thu Nov 16 19:19:33 +0000 2017 X-GM-THRID: 1582790467810046578 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread