From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Barnes Subject: Re: [PATCH 2/2] drm/i915/vlv: use correct units for rc6 residency Date: Thu, 26 Sep 2013 17:51:16 -0700 Message-ID: <20130926175116.436024eb@jbarnes-desktop> References: <1380224001-16427-1-git-send-email-jbarnes@virtuousgeek.org> <1380224001-16427-2-git-send-email-jbarnes@virtuousgeek.org> <20130926222546.GB21482@nuc-i3427.alporthouse.com> <20130926153433.7da65333@jbarnes-desktop> <20130927004937.GA8626@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from oproxy13-pub.mail.unifiedlayer.com (oproxy13-pub.mail.unifiedlayer.com [69.89.16.30]) by gabe.freedesktop.org (Postfix) with SMTP id B1106E71FD for ; Thu, 26 Sep 2013 17:51:11 -0700 (PDT) In-Reply-To: <20130927004937.GA8626@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Fri, 27 Sep 2013 01:49:37 +0100 Chris Wilson wrote: > On Thu, Sep 26, 2013 at 03:34:33PM -0700, Jesse Barnes wrote: > > On Thu, 26 Sep 2013 23:25:46 +0100 > > Chris Wilson wrote: > > > > > > > > > > > if (!intel_enable_rc6(dev)) > > > > return 0; > > > > > > > > - raw_time = I915_READ(reg) * 128ULL; > > > > - return DIV_ROUND_UP_ULL(raw_time, 100000); > > > > + /* On VLV, residency time is in CZ units rather than 1.28us */ > > > > + if (IS_VALLEYVIEW(dev)) { > > > > + u32 clkctl2; > > > > + > > > > + clkctl2 = I915_READ(VLV_CLK_CTL2) >> > > > > + CLK_CTL2_CZCOUNT_30NS_SHIFT; > > > > + if (!clkctl2) { > > > > + WARN(!clkctl2, "bogus CZ count value"); > > > > + return 0; > > > > + } > > > > + units = DIV_ROUND_UP_ULL(3000ULL, (u64)clkctl2); > > > > > > For your divisor, this should 30*1000 not 3*1000. > > > > 30ns * 100 for fixed point precision, just as above. > > > > > > > > > + if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH) > > > > + units <<= 8; > > > > + > > > > + div = 100 000 000; > > > > Then here we divide out the ns to ms (1000000) and also the 100 for > > fixed point. > > > > Or do I still have it wrong? > > Just counting fail on my part, even after splitting it up to make it > easier for myself. > > How about > > #define BIAS 100 > units = 30*BIAS / cltctk2; > if (hi) units <<= 8; > div = NSEC_PER_MSEC * BIAS; > > All because I have difficultly counting. Sure, will re-post. Thanks, -- Jesse Barnes, Intel Open Source Technology Center