[PATCH] drm/i915: rc6 residency (fix the fix)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 22 Apr 2012 18:39:23 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:

> On Sun, 22 Apr 2012 10:35:29 -0700, Ben Widawsky <ben at bwidawsk.net>
> wrote:
> > On Sun, 22 Apr 2012 16:49:53 +0100
> > Chris Wilson <chris at chris-wilson.co.uk> wrote:
> > 
> > > On Fri, 20 Apr 2012 11:50:01 -0700, Ben Widawsky
> > > <ben at bwidawsk.net> wrote:
> > > > Chris' fix for my 32b breakage was incorrect. do_div returns a
> > > > remainder. Go back to a divide macro which is more 32b friendly.
> > > > 
> > > > Tested on x86-64.
> > > > 
> > > > This has only been compile tested on 32b systems.
> > > Doesn't compile on my 32-bit systems.
> > > 
> > > Still does a 64-bit divide.
> > 
> > This is weird. I don't understand what's broken exactly. It should
> > be dividing an unsigned long long, which the 32b compiler should
> > have no issue with. The macro itself expands to do_div which was
> > your original fix.
> > 
> > What is the error message you get?
> Undefined reference to __udivid3.
> 
> The reason is that the result of DIV_ROUND_UP_ULL is a 64-bit value,
> which we then proceed to divide by 100.
> -Chris
> 

For the sake of picking nits, this is a linker fail, not a compiler one.
The only reason I make note of it is I was only compiling the .ko when
I did my testing.

So lesson learned, can't we just:

diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index bd6350b..79f8344 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -40,7 +40,7 @@ static u32 calc_residency(struct drm_device *dev, const u32 reg)
                return 0;
 
        raw_time = I915_READ(reg) * 128ULL;
-       return DIV_ROUND_UP_ULL(raw_time, 1000) / 100;
+       return DIV_ROUND_UP_ULL(raw_time, 100000);
 }
 
 static ssize_t



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux