Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934860AbcLOMAz convert rfc822-to-8bit (ORCPT ); Thu, 15 Dec 2016 07:00:55 -0500 Received: from mga05.intel.com ([192.55.52.43]:15703 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751644AbcLOMAy (ORCPT ); Thu, 15 Dec 2016 07:00:54 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,351,1477983600"; d="scan'208";a="798288510" From: Jani Nikula To: Nicholas Mc Guire Cc: Ville =?utf-8?B?U3lyasOkbMOk?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Nicholas Mc Guire , Daniel Vetter Subject: Re: [PATCH] drm/i915: use udelay for very short delays In-Reply-To: <20161215103400.GA26125@osadl.at> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <1481776147-23041-1-git-send-email-hofrat@osadl.org> <87wpf1pnj2.fsf@intel.com> <20161215092830.GA25458@osadl.at> <87mvfxpli5.fsf@intel.com> <20161215101036.GW31595@intel.com> <87k2b1pk8e.fsf@intel.com> <20161215103400.GA26125@osadl.at> Date: Thu, 15 Dec 2016 13:48:38 +0200 Message-ID: <87h965pg4p.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2896 Lines: 64 On Thu, 15 Dec 2016, Nicholas Mc Guire wrote: > On Thu, Dec 15, 2016 at 12:20:01PM +0200, Jani Nikula wrote: >> On Thu, 15 Dec 2016, Ville Syrjälä wrote: >> > On Thu, Dec 15, 2016 at 11:52:34AM +0200, Jani Nikula wrote: >> >> On Thu, 15 Dec 2016, Nicholas Mc Guire wrote: >> >> > On Thu, Dec 15, 2016 at 11:08:49AM +0200, Jani Nikula wrote: >> >> >> On Thu, 15 Dec 2016, Nicholas Mc Guire wrote: >> >> >> > Even on fast systems a 2 microsecond delay is most likely more efficient >> >> >> > as a busy-wait loop. The overhead of a hrtimer does not seem warranted - >> >> >> > change this to a udelay(2). >> >> >> >> >> >> Similar concerns as in [1]. We don't need the accuracy of udelay() here, >> >> >> so this boils down to which is the better use of CPU. We could probably >> >> >> relax the max delay more if that was helpful. But I'm not immediately >> >> >> sold on "is most likely more efficient" which sounds like a gut feeling. >> >> >> >> >> >> I'm sorry it's not clear in my other reply that I do appreciate >> >> >> addressing incorrect/silly use of usleep_range(); I'm just not (yet) >> >> >> convinced udelay() is the answer. >> >> > >> >> > if the delay is not critical and all that is needed >> >> > is an assurance that it is greater than X us then >> >> > usleep_range is fine with a relaxed limit. >> >> > So from what you wrote my patch proposal is wrong - the >> >> > udelay() is not the way to got. >> >> > My intent is to get rid of very small usleep_range() cases >> >> > so if usleep_range(20,50) causes no issues with this driver >> >> > and does not induce any performance penalty then that would >> >> > be the way to go I think. >> >> >> >> Okay, so I looked at the code, and I looked at our spec, and I looked at >> >> the MIPI D-PHY spec, and I cried a little. >> >> >> >> Long story short, I think usleep_range(10, 50) will be fine. >> > >> > Note that I really want to see a comment next to every delay like this >> > documenting the actual hardware requirement, if the delay used by the >> > code doesn't 100% match it. >> >> Our spec says, "Wait for 2us for ULPS to complete". That's a simplistic >> view wrt D-PHY, and our code doesn't even match the spec. Hence the >> tears. Want to propose a wording for the comment so we can apply this >> change, without going for a full rewrite of the sequence? >> > is that suitable or am I overdoing it ? > > - usleep_range(2, 3); > + /* delay for at least 2us - relaxed to 10-50 to allow > + * hrtimer subsystem to optimize uncritical timer handling > + */ > + usleep_range(10, 50); I'm fine with that. Or maybe just make it "relaxed to allow" without the values. Jani. > > thx! > hofrat -- Jani Nikula, Intel Open Source Technology Center