drm/i915: don't use stolen space on VLV
Subsystems (2)
PATCH 1/3 drm/i915: don't use stolen space on VLV
BIOS stuffs things here we can't clobber.
--- drivers/gpu/drm/i915/i915_gem_stolen.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -0
@@ -184,6 +184,9 @@ int i915_gem_init_stolen(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (IS_VALLEYVIEW (dev)) +return 0 ; + dev_priv->mm.stolen_base =i915_stolen_to_physical (dev);if (dev_priv->mm.stolen_base ==0 )return 0 ;
Signature · 1 line
1.7.10.4
PATCH 2/3 drm/i915: read current freq from Punit on VLV
Instead of returning the cached value, which is just what the kernel requested.
--- drivers/gpu/drm/i915/i915_sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_sysfs.c +6 -3
@@ -212,10 +212,13 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev,int ret;mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) - ret =vlv_gpu_freq (dev_priv->mem_freq, dev_priv->rps.cur_delay); -else +if (IS_VALLEYVIEW (dev_priv->dev)) { +u32 freq; +valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &freq); + ret =vlv_gpu_freq (dev_priv->mem_freq, (freq >>8 ) &0xff ); + }else { ret = dev_priv->rps.cur_delay *GT_FREQUENCY_MULTIPLIER ; + }mutex_unlock (&dev_priv->rps.hw_lock);return snprintf (buf,PAGE_SIZE ,"%d\n" , ret);
Signature · 1 line
1.7.10.4
Re: [PATCH 2/3] drm/i915: read current freq from Punit on VLV
Quoted 19 lines · Jesse Barnes
Instead of returning the cached value, which is just what the kernel requested.
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/i915_sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_sysfs.c +0
-3@@ -212,10 +212,13 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev,int ret;mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) - ret =vlv_gpu_freq (dev_priv->mem_freq, dev_priv->rps.cur_delay); -else
drivers/gpu/drm/i915/i915_sysfs.c static ssize_t gt_cur_freq_mhz_show(struct device *kdev, · line 224
Quoted 10 lines
drivers/gpu/drm/i915/i915_sysfs.c +6
-0+if (IS_VALLEYVIEW (dev_priv->dev)) { +u32 freq; +valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &freq); + ret =vlv_gpu_freq (dev_priv->mem_freq, (freq >>8 ) &0xff ); + }else { ret = dev_priv->rps.cur_delay *GT_FREQUENCY_MULTIPLIER ; + }mutex_unlock (&dev_priv->rps.hw_lock);return snprintf (buf,PAGE_SIZE ,"%d\n" , ret);
I'd really like to see this for the rest of the platforms as well. Knowing what the kernel requested isn't nearly as interesting as knowing the real value.
But this VLV patch looks great, so:
I'm not planning on reviewing patch 1; I have no idea about any of that stuff.
PATCH 3/3 drm/i915: go back to switch for VLV mem freq detection
In reply to Jesse BarnesWe need to catch the invalid case and override it.
--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +15 -1
@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 : + dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );
Signature · 1 line
1.7.10.4
Re: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
Quoted 24 lines · Jesse Barnes
We need to catch the invalid case and override it.
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +8
-1@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 :
drivers/gpu/drm/i915/intel_pm.c static void valleyview_enable_rps(struct drm_device *dev) · line 2922
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +7
-0+ dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );
I guess it doesn't handle the last case, but:dev_priv->mem_freq = 800 + (266 * (val))) + val/2
or
u32 freqs[] = {800,1066,1333,800};dev_priv->mem_freq = freqs[(val >> 6) & 3];
Are two ways I would have used before making a switch block :P
Just a thought, but perhaps we don't want to enable RPS if we can't reliably figure out the memory freq. (case 3)
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Kenneth Graunke
Reviewed-byRe: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
Quoted 4 lines · Ben Widawsky
Quoted 3 lines · Jesse Barnes
We need to catch the invalid case and override it.
Signed-off-by Jesse Barnes <[email protected]>
Jesse, it's actually worse than that:
Your parenthesis were off in the previous version, causing it to do the multiplication by 266 before the bitwise-and:
800 + ((266 * (val >> 6)) & 3)
This meant that you always got 800 or 802 Mhz.
Also, even when corrected, your previous formula would return 1332 Mhz instead of 1333 Mhz, which is slightly off and doesn't work since you use it in explicit switch statements.
It might be worth mentioning in the commit message.
Quoted 30 lines
Quoted 30 lines
--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +15
-1@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 : + dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);
Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c static void valleyview_enable_rps(struct drm_device *dev) · line 2922
Quoted 1 line
drivers/gpu/drm/i915/intel_pm.c +0
-0DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );I guess it doesn't handle the last case, but:
dev_priv->mem_freq= 800 + (266 * (val))) + val/2
Don't use this method. Presumably Ben meant (val >> 6) here, but even with that fix this formula returns 1067 rather than 1066, which is wrong.
Quoted 4 lines
or
u32 freqs[] = {800,1066,1333,800};
dev_priv->mem_freq= freqs[(val >> 6) & 3];
I like this table based approach best. It's much more succinct than the switch statement, and exact. Might be worth preserving the DRM_ERROR.
Quoted 6 lines
Are two ways I would have used before making a switch block :P
Just a thought, but perhaps we don't want to enable RPS if we can't reliably figure out the memory freq. (case 3)
Reviewed-by Ben Widawsky <[email protected]>
For either the switch or Ben's table:
Incidentally, my Punit returns 3 here, but I believe the memory is actually 1066. Not sure what the deal is.
--Ken
Re: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
Quoted 57 lines · Kenneth Graunke
Quoted 4 lines · Ben Widawsky
Quoted 3 lines · Jesse Barnes
We need to catch the invalid case and override it.
Signed-off-by Jesse Barnes <[email protected]>Jesse, it's actually worse than that:
Your parenthesis were off in the previous version, causing it to do the multiplication by 266 before the bitwise-and:
800 + ((266 * (val >> 6)) & 3)This meant that you always got 800 or 802 Mhz.
Also, even when corrected, your previous formula would return 1332 Mhz instead of 1333 Mhz, which is slightly off and doesn't work since you use it in explicit switch statements.
It might be worth mentioning in the commit message.
Quoted 30 lines
Quoted 30 lines
--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +15
-1@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 : + dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c static void valleyview_enable_rps(struct drm_device *dev) · line 2922
Quoted 1 line
drivers/gpu/drm/i915/intel_pm.c +0
-0DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );I guess it doesn't handle the last case, but:
dev_priv->mem_freq= 800 + (266 * (val))) + val/2
Quoted 3 lines
Don't use this method. Presumably Ben meant (val >> 6) here, but even with that fix this formula returns 1067 rather than 1066, which is wrong.
You're right about the missing shift, but otherwise the formula is correct. Val is 1 in the case of 1066MHz...
Quoted 28 lines
Quoted 5 lines
or
u32 freqs[] = {800,1066,1333,800};
dev_priv->mem_freq= freqs[(val >> 6) & 3];I like this table based approach best. It's much more succinct than the switch statement, and exact. Might be worth preserving the
DRM_ERROR.Quoted 6 lines
Are two ways I would have used before making a switch block :P
Just a thought, but perhaps we don't want to enable RPS if we can't reliably figure out the memory freq. (case 3)
Reviewed-by Ben Widawsky <[email protected]>For either the switch or Ben's table:
Reviewed-by Kenneth Graunke <[email protected]>Incidentally, my Punit returns 3 here, but I believe the memory is actually 1066. Not sure what the deal is.
--Ken
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
Quoted 58 lines · Ben Widawsky
Quoted 57 lines · Kenneth Graunke
Quoted 4 lines · Ben Widawsky
Quoted 3 lines · Jesse Barnes
We need to catch the invalid case and override it.
Signed-off-by Jesse Barnes <[email protected]>Jesse, it's actually worse than that:
Your parenthesis were off in the previous version, causing it to do the multiplication by 266 before the bitwise-and:
800 + ((266 * (val >> 6)) & 3)This meant that you always got 800 or 802 Mhz.
Also, even when corrected, your previous formula would return 1332 Mhz instead of 1333 Mhz, which is slightly off and doesn't work since you use it in explicit switch statements.
It might be worth mentioning in the commit message.
Quoted 35 lines
Quoted 21 lines
--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +8
-1@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 :drivers/gpu/drm/i915/intel_pm.c static void valleyview_enable_rps(struct drm_device *dev) · line 2922
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +7
-0+ dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );I guess it doesn't handle the last case, but:
dev_priv->mem_freq= 800 + (266 * (val))) + val/2
Quoted 29 lines
Quoted 3 lines
Don't use this method. Presumably Ben meant (val >> 6) here, but even with that fix this formula returns 1067 rather than 1066, which is wrong.
You're right about the missing shift, but otherwise the formula is correct. Val is 1 in the case of 1066MHz...
Quoted 22 lines
Quoted 5 lines
or
u32 freqs[] = {800,1066,1333,800};
dev_priv->mem_freq= freqs[(val >> 6) & 3];I like this table based approach best. It's much more succinct than the switch statement, and exact. Might be worth preserving the
DRM_ERROR.Quoted 6 lines
Are two ways I would have used before making a switch block :P
Just a thought, but perhaps we don't want to enable RPS if we can't reliably figure out the memory freq. (case 3)
Reviewed-by Ben Widawsky <[email protected]>For either the switch or Ben's table:
Reviewed-by Kenneth Graunke <[email protected]>Incidentally, my Punit returns 3 here, but I believe the memory is actually 1066. Not sure what the deal is.
You're right - my mistake, sorry. I had been doing this in a python interpreter and accidentally put 0b01 for the first val and 0b10 for the second val.
--Ken
Re: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
In reply to Ben WidawskyQuoted 34 lines · Ben Widawsky
Quoted 33 lines · Jesse Barnes
We need to catch the invalid case and override it.
Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/intel_pm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_pm.c +15
-1@@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev) GEN7_RC_CTL_TO_MODE);valleyview_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS , &val); - dev_priv->mem_freq =800 + (266 * (val >>6 ) &3 ); +switch ((val >>6 ) &3 ) { +case 0 : + dev_priv->mem_freq =800 ; +break ; +case 1 : + dev_priv->mem_freq =1066 ; +break ; +case 2 : + dev_priv->mem_freq =1333 ; +break ; +case 3 : +DRM_ERROR ("invalid mem freq, assuming 800MHz\n" ); + dev_priv->mem_freq =800 ; +break ; + }DRM_DEBUG_DRIVER ("DDR speed: %d MHz" , dev_priv->mem_freq);
Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c static void valleyview_enable_rps(struct drm_device *dev) · line 2922
Quoted 1 line
drivers/gpu/drm/i915/intel_pm.c +0
-0DRM_DEBUG_DRIVER ("GPLL enabled? %s\n" , val &0x10 ?"yes" :"no" );I guess it doesn't handle the last case, but:
dev_priv->mem_freq= 800 + (266 * (val))) + val/2
conveniently, I've given you the reason not to use this one... error prone. It's missing a:
val = (val >> 6) & 3
before the math.
Quoted 18 lines
or
u32 freqs[] = {800,1066,1333,800};
dev_priv->mem_freq= freqs[(val >> 6) & 3];Are two ways I would have used before making a switch block :P
Just a thought, but perhaps we don't want to enable RPS if we can't reliably figure out the memory freq. (case 3)
Reviewed-by Ben Widawsky <[email protected]>Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 3 lines · Jesse Barnes
BIOS stuffs things here we can't clobber.
Signed-off-by Jesse Barnes <[email protected]>
As I said in private email, I think the quirk is a bit better suited in i915_stolen_to_physical(), and the commit message *could* explain things a bit clearer, oh, and you're welcome.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center