Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935930AbcLOJdR (ORCPT ); Thu, 15 Dec 2016 04:33:17 -0500 Received: from mga05.intel.com ([192.55.52.43]:51381 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935618AbcLOJdO (ORCPT ); Thu, 15 Dec 2016 04:33:14 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,351,1477983600"; d="scan'208";a="798250898" From: Jani Nikula To: Nicholas Mc Guire Cc: Nicholas Mc Guire , Daniel Vetter , ymohanma , David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/i915: use udelay for very small delays In-Reply-To: <20161215085651.GA25256@osadl.at> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <1481774609-20998-1-git-send-email-hofrat@osadl.org> <8737hpr32a.fsf@intel.com> <20161215085651.GA25256@osadl.at> Date: Thu, 15 Dec 2016 11:33:11 +0200 Message-ID: <87r359pmeg.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2345 Lines: 59 On Thu, 15 Dec 2016, Nicholas Mc Guire wrote: > On Thu, Dec 15, 2016 at 10:47:57AM +0200, Jani Nikula wrote: >> On Thu, 15 Dec 2016, Nicholas Mc Guire wrote: >> > usleep_range() is intended for delays in the 10us to 10ms range that need >> > good precision. a useleep_range(1, will effectively be no more than an >> > imprecise udelay with some added cache disruption as it will fire more or >> > less immediately - use udelay() here. >> > >> > Fixes: commit be4fc046bed3 ("drm/i915: add VLV DSI PLL Calculations") >> > Signed-off-by: Nicholas Mc Guire >> > --- >> > >> > Problem located by coccinelle >> > >> > The requirement of waiting at least 0.5 us is assured with the udelay(1) >> > here which should be more effective than a usleep_range() - would >> > ndelay(500) make sense here ? >> >> This is in the modeset path, i.e. pretty slow anyway. In this case, the >> point is not to try hard to minimize the wait, the point is to guarantee >> "at least 0.5 us" has passed. If the CPU can do something else, >> including dozing off, in the mean time, great. I think we should stick >> with usleep_range(). > > well in that case maybe an acceptable solution would be to set it to > some suitable range 10,20 us ? or if not critical preferably even with a large > upper limit. I'd be fine with 10, 50 here. Please do send the patch, Cc: me. >> >> I think the question is, how do we express this in code? IMO udelay() is >> not the answer. > > if the delay need to be kept short then no - then its not the answer > but usleep_ranges(1,2) I think is effectively just an inefficient version > of udelay(1), by the time the timer is setup and the task gives > up the cpu the timer would fire. > >> >> And why doesn't usleep_range() kernel-doc mention anything about the >> ranges? >> > > interesting - that might be part of the reason there are many findings > Documentation/timers/timers-howto.txt does > > SLEEPING FOR ~USECS OR SMALL MSECS ( 10us - 20ms): > * Use usleep_range I'd appreciate short additions to the kernel-doc documentation of each function to document the approximate range it's appropriate for. People will know where to look if their use doesn't fall in that range. Thanks, Jani. -- Jani Nikula, Intel Open Source Technology Center