drm/i915: Extract PCU communication
Subsystems (2)
PATCH 1/3 drm/i915: Extract PCU communication
There is a special mechanism for communicating with the PCU already being used for the ring frequency stuff. As we'll be needing this for other commands, extract it now to make future code less error prone and the current code more reusable.
I'm not entirely sure if this code matches 1:1 with the previous code behaviorally. Functionally however, it should be the same.
--- drivers/gpu/drm/i915/i915_debugfs.c | 13 ++--- drivers/gpu/drm/i915/i915_drv.h | 3 ++ drivers/gpu/drm/i915/intel_pm.c | 94 +++++++++++++++++++++++-------------- 3 files changed, 67 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -9
@@ -1283,15 +1283,10 @@ static int i915_ring_freq_table(struct seq_file *m, void *unused)for (gpu_freq = dev_priv->rps.min_delay; gpu_freq <= dev_priv->rps.max_delay; gpu_freq++) { -I915_WRITE (GEN6_PCODE_DATA , gpu_freq); -I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_PCODE_READY | -GEN6_PCODE_READ_MIN_FREQ_TABLE ); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) & -GEN6_PCODE_READY ) ==0 ,10 )) { -DRM_ERROR ("pcode read of freq table timed out\n" ); -continue ; - } - ia_freq =I915_READ (GEN6_PCODE_DATA ); + ia_freq = gpu_freq; +sandybridge_pcode_read (dev_priv, +GEN6_PCODE_READ_MIN_FREQ_TABLE , + &ia_freq);seq_printf (m,"%d\t\t%d\n" , gpu_freq *GT_FREQUENCY_MULTIPLIER , ia_freq *100 ); }
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -1622,6 +1622,9 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);void gen6_gt_force_wake_put (struct drm_i915_private *dev_priv);int __gen6_gt_wait_for_fifo (struct drm_i915_private *dev_priv); +int sandybridge_pcode_read (struct drm_i915_private *dev_priv,u8 mbox,u32 *val); +int sandybridge_pcode_write (struct drm_i915_private *dev_priv,u8 mbox,u32 val); +#define __i915_read (x, y) \ u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg);
drivers/gpu/drm/i915/intel_pm.c +60 -34
110 lines not on this page · raw message
Signature · 1 line
1.7.12.1
PATCH 2/3 drm/i915: Workaround to bump rc6 voltage to 450
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a DRM_ERROR for the user to see.
Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
--- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ drivers/gpu/drm/i915/intel_pm.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -4213,6 +4213,10 @@#define GEN6_READ_OC_PARAMS 0xc#define GEN6_PCODE_WRITE_MIN_FREQ_TABLE 0x8#define GEN6_PCODE_READ_MIN_FREQ_TABLE 0x9 +#define GEN6_PCODE_WRITE_RC6VIDS 0x4 +#define GEN6_PCODE_READ_RC6VIDS 0x5 +#define GEN6_ENCODE_RC6_VID (mv) (((mv) / 5) - 245) < 0 ?: 0 +#define GEN6_DECODE_RC6_VID (vids) (((vids) * 5) > 0 ? ((vids) * 5) + 245 : 0)#define GEN6_PCODE_DATA 0x138128#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8
drivers/gpu/drm/i915/intel_pm.c +16 -2
@@ -2404,10 +2404,10 @@ static void gen6_enable_rps(struct drm_device *dev)struct intel_ring_buffer *ring;u32 rp_state_cap;u32 gt_perf_status; -u32 pcu_mbox, rc6_mask =0 ; +u32 rc6vids, pcu_mbox, rc6_mask =0 ;u32 gtfifodbg;int rc6_mode; -int i; +int i, ret;WARN_ON (!mutex_is_locked (&dev->struct_mutex));
@@ -2526,6 +2526,20 @@ static void gen6_enable_rps(struct drm_device *dev)/* enable all PM interrupts */ I915_WRITE (GEN6_PMINTRMSK ,0 ); + rc6vids =0 ; + ret =sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids); +if (IS_GEN6 (dev) && ret) { +DRM_DEBUG_DRIVER ("Couldn't check for BIOS workaround\n" ); + }else if (IS_GEN6 (dev) && (GEN6_DECODE_RC6_VID (rc6vids &0xff ) <450 )) { +DRM_ERROR ("You should update your BIOS. Correcting minimum rc6 voltage (%dmV->%dmV)\n" , +GEN6_DECODE_RC6_VID (rc6vids &0xff ),450 ); + rc6vids &=0xffff00 ; + rc6vids |=GEN6_ENCODE_RC6_VID (450 ); + ret =sandybridge_pcode_write (dev_priv,GEN6_PCODE_WRITE_RC6VIDS , rc6vids); +if (ret) +DRM_ERROR ("Couldn't fix incorrect rc6 voltage\n" ); + } +gen6_gt_force_wake_put (dev_priv); }
Signature · 1 line
1.7.12.1
Re: [PATCH 2/3] drm/i915: Workaround to bump rc6 voltage to 450
Quoted 71 lines · Ben Widawsky
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a
DRM_ERRORfor the user to see.Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
CC Jesse Barnes <[email protected]>CC Matt Turner <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ drivers/gpu/drm/i915/intel_pm.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_reg.h +4
-0@@ -4213,6 +4213,10 @@#define GEN6_READ_OC_PARAMS 0xc#define GEN6_PCODE_WRITE_MIN_FREQ_TABLE 0x8#define GEN6_PCODE_READ_MIN_FREQ_TABLE 0x9 +#define GEN6_PCODE_WRITE_RC6VIDS 0x4 +#define GEN6_PCODE_READ_RC6VIDS 0x5 +#define GEN6_ENCODE_RC6_VID (mv) (((mv) / 5) - 245) < 0 ?: 0 +#define GEN6_DECODE_RC6_VID (vids) (((vids) * 5) > 0 ? ((vids) * 5) + 245 : 0)#define GEN6_PCODE_DATA 0x138128#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8drivers/gpu/drm/i915/intel_pm.c +16
-3@@ -2404,10 +2404,10 @@ static void gen6_enable_rps(struct drm_device *dev)struct intel_ring_buffer *ring;u32 rp_state_cap;u32 gt_perf_status; -u32 pcu_mbox, rc6_mask =0 ; +u32 rc6vids, pcu_mbox, rc6_mask =0 ;u32 gtfifodbg;int rc6_mode; -int i; +int i, ret;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -2526,6 +2526,20 @@ static void gen6_enable_rps(struct drm_device *dev)/* enable all PM interrupts */ I915_WRITE (GEN6_PMINTRMSK ,0 ); + rc6vids =0 ; + ret =sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids); +if (IS_GEN6 (dev) && ret) { +DRM_DEBUG_DRIVER ("Couldn't check for BIOS workaround\n" ); + }else if (IS_GEN6 (dev) && (GEN6_DECODE_RC6_VID (rc6vids &0xff ) <450 )) { +DRM_ERROR ("You should update your BIOS. Correcting minimum rc6 voltage (%dmV->%dmV)\n" , +GEN6_DECODE_RC6_VID (rc6vids &0xff ),450 ); + rc6vids &=0xffff00 ; + rc6vids |=GEN6_ENCODE_RC6_VID (450 ); + ret =sandybridge_pcode_write (dev_priv,GEN6_PCODE_WRITE_RC6VIDS , rc6vids); +if (ret) +DRM_ERROR ("Couldn't fix incorrect rc6 voltage\n" ); + } +gen6_gt_force_wake_put (dev_priv); } --
Quoted 2 lines
1.7.12.1
(feel free to apply that to the whole series)
Too bad it's not this bug that affects my system. :(
Re: [PATCH 2/3] drm/i915: Workaround to bump rc6 voltage to 450
In reply to Ben WidawskyQuoted 60 lines · On Wed, 26 Sep 2012 10:34:01 -0700 Ben Widawsky <[email protected]> wrote:
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a
DRM_ERRORfor the user to see.Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
CC Jesse Barnes <[email protected]>CC Matt Turner <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ drivers/gpu/drm/i915/intel_pm.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_reg.h +4
-0@@ -4213,6 +4213,10 @@#define GEN6_READ_OC_PARAMS 0xc#define GEN6_PCODE_WRITE_MIN_FREQ_TABLE 0x8#define GEN6_PCODE_READ_MIN_FREQ_TABLE 0x9 +#define GEN6_PCODE_WRITE_RC6VIDS 0x4 +#define GEN6_PCODE_READ_RC6VIDS 0x5 +#define GEN6_ENCODE_RC6_VID (mv) (((mv) / 5) - 245) < 0 ?: 0 +#define GEN6_DECODE_RC6_VID (vids) (((vids) * 5) > 0 ? ((vids) * 5) + 245 : 0)#define GEN6_PCODE_DATA 0x138128#define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8drivers/gpu/drm/i915/intel_pm.c +9
-2@@ -2404,10 +2404,10 @@ static void gen6_enable_rps(struct drm_device *dev)struct intel_ring_buffer *ring;u32 rp_state_cap;u32 gt_perf_status; -u32 pcu_mbox, rc6_mask =0 ; +u32 rc6vids, pcu_mbox, rc6_mask =0 ;u32 gtfifodbg;int rc6_mode; -int i; +int i, ret;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -2526,6 +2526,20 @@ static void gen6_enable_rps(struct drm_device *dev)/* enable all PM interrupts */ I915_WRITE (GEN6_PMINTRMSK ,0 ); + rc6vids =0 ; + ret =sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids); +if (IS_GEN6 (dev) && ret) { +DRM_DEBUG_DRIVER ("Couldn't check for BIOS workaround\n" ); + }else if (IS_GEN6 (dev) && (GEN6_DECODE_RC6_VID (rc6vids &0xff ) <450 )) { +DRM_ERROR ("You should update your BIOS. Correcting minimum rc6 voltage (%dmV->%dmV)\n" , +GEN6_DECODE_RC6_VID (rc6vids &0xff ),450 );
drivers/gpu/drm/i915/intel_pm.c static void gen6_enable_rps(struct drm_device *dev) · line 2545
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +7
-0+ rc6vids &=0xffff00 ; + rc6vids |=GEN6_ENCODE_RC6_VID (450 ); + ret =sandybridge_pcode_write (dev_priv,GEN6_PCODE_WRITE_RC6VIDS , rc6vids); +if (ret) +DRM_ERROR ("Couldn't fix incorrect rc6 voltage\n" ); + } +gen6_gt_force_wake_put (dev_priv); }
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Dave Airlie
maintainerRe: [PATCH 2/3] drm/i915: Workaround to bump rc6 voltage to 450
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 26 Sep 2012 10:34:01 -0700 Ben Widawsky <[email protected]> wrote:
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a
DRM_ERRORfor the user to see.Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
Yeah drop the DRM_ERROR, it should be DRM_INFO at worst, and non-existant at best.
Who gives a shit if you have to upgrade your BIOS, lots of vendors won't provide updates and I don't see Intel doing anything to solve that.
Dave.
Re: [PATCH 2/3] drm/i915: Workaround to bump rc6 voltage to 450
Quoted 13 lines · On Fri, 28 Sep 2012 10:13:26 +1000 Dave Airlie <[email protected]> wrote:
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 26 Sep 2012 10:34:01 -0700 Ben Widawsky <[email protected]> wrote:
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a
DRM_ERRORfor the user to see.Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
Quoted 8 lines
Yeah drop the
DRM_ERROR, it should beDRM_INFOat worst, and non-existant at best.Who gives a shit if you have to upgrade your BIOS, lots of vendors won't provide updates and I don't see Intel doing anything to solve that.
Dave.
I dunno, messing with voltages seems pretty scary to me. I'd really like a loud warning when the driver does it. I perhaps agree that telling the user to update the BIOS isn't a message we want to classify as an ERROR. I think at least a DRM_DEBUG_DRIVER, but I give Daniel permission to change it as he sees fit assuming the rest of the patch is fine for everyone.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 2/3] drm/i915: Workaround to bump rc6 voltage to 450
Quoted 26 lines · Ben Widawsky
Quoted 13 lines · On Fri, 28 Sep 2012 10:13:26 +1000 Dave Airlie <[email protected]> wrote:
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 26 Sep 2012 10:34:01 -0700 Ben Widawsky <[email protected]> wrote:
BIOS should be setting the minimum voltage for rc6 to be 450mV. Old or buggy BIOSen may not be doing this, so we correct it for them. Ideally customers should update the BIOS as only it would know the optimal values for the platform, so we leave that fact as a
DRM_ERRORfor the user to see.Unfortunately this isn't fixing any of the issues it was targeted to fix, but it is documented that we must do it.
Quoted 8 lines
Yeah drop the
DRM_ERROR, it should beDRM_INFOat worst, and non-existant at best.Who gives a shit if you have to upgrade your BIOS, lots of vendors won't provide updates and I don't see Intel doing anything to solve that.
Dave.
Quoted 6 lines
I dunno, messing with voltages seems pretty scary to me. I'd really like a loud warning when the driver does it. I perhaps agree that telling the user to update the BIOS isn't a message we want to classify as an ERROR. I think at least a
DRM_DEBUG_DRIVER, but I give Daniel permission to change it as he sees fit assuming the rest of the patch is fine for everyone.
Merged these 2 patches, too, with the error tuned down to a debug message.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 3/3 drm/i915: Add rc6vids to debugfs
In reply to Ben Widawsky--- drivers/gpu/drm/i915/i915_debugfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +8 -1
@@ -1069,7 +1069,7 @@ static int gen6_drpc_info(struct seq_file *m)struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private; -u32 rpmodectl1, gt_core_status, rcctl1; +u32 rpmodectl1, gt_core_status, rcctl1, rc6vids =0 ;unsigned forcewake_count;int count=0 , ret;
@@ -1097,6 +1097,7 @@ static int gen6_drpc_info(struct seq_file *m) rpmodectl1 =I915_READ (GEN6_RP_CONTROL ); rcctl1 =I915_READ (GEN6_RC_CONTROL ); +sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids);mutex_unlock (&dev->struct_mutex); seq_printf(m, "Video Turbo Mode: %s\n",
@@ -1149,6 +1150,12 @@ static int gen6_drpc_info(struct seq_file *m)seq_printf (m,"RC6++ residency since boot: %u\n" ,I915_READ (GEN6_GT_GFX_RC6pp)); +seq_printf (m,"RC6 voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>0 ) &0xff ))); +seq_printf (m,"RC6+ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>8 ) &0xff ))); +seq_printf (m,"RC6++ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>16 ) &0xff )));return 0 ; }
Signature · 1 line
1.7.12.1
Re: [PATCH 3/3] drm/i915: Add rc6vids to debugfs
Quoted 30 lines · On Wed, 26 Sep 2012 10:34:02 -0700 Ben Widawsky <[email protected]> wrote:
CC Jesse Barnes <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-1@@ -1069,7 +1069,7 @@ static int gen6_drpc_info(struct seq_file *m)struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private; -u32 rpmodectl1, gt_core_status, rcctl1; +u32 rpmodectl1, gt_core_status, rcctl1, rc6vids =0 ;unsigned forcewake_count;int count=0 , ret;@@ -1097,6 +1097,7 @@ static int gen6_drpc_info(struct seq_file *m) rpmodectl1 =I915_READ (GEN6_RP_CONTROL ); rcctl1 =I915_READ (GEN6_RC_CONTROL ); +sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids);mutex_unlock (&dev->struct_mutex); seq_printf(m, "Video Turbo Mode: %s\n",@@ -1149,6 +1150,12 @@ static int gen6_drpc_info(struct seq_file *m)seq_printf (m,"RC6++ residency since boot: %u\n" ,I915_READ (GEN6_GT_GFX_RC6pp));
drivers/gpu/drm/i915/i915_debugfs.c static int gen6_drpc_info(struct seq_file *m) · line 1161
Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +6
-0+seq_printf (m,"RC6 voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>0 ) &0xff ))); +seq_printf (m,"RC6+ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>8 ) &0xff ))); +seq_printf (m,"RC6++ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>16 ) &0xff )));return 0 ; }
Nice.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Daniel Vetter
AppliedRe: [PATCH 3/3] drm/i915: Add rc6vids to debugfs
Quoted 46 lines · Jesse Barnes
Quoted 30 lines · On Wed, 26 Sep 2012 10:34:02 -0700 Ben Widawsky <[email protected]> wrote:
CC Jesse Barnes <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-1@@ -1069,7 +1069,7 @@ static int gen6_drpc_info(struct seq_file *m)struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private; -u32 rpmodectl1, gt_core_status, rcctl1; +u32 rpmodectl1, gt_core_status, rcctl1, rc6vids =0 ;unsigned forcewake_count;int count=0 , ret;@@ -1097,6 +1097,7 @@ static int gen6_drpc_info(struct seq_file *m) rpmodectl1 =I915_READ (GEN6_RP_CONTROL ); rcctl1 =I915_READ (GEN6_RC_CONTROL ); +sandybridge_pcode_read (dev_priv,GEN6_PCODE_READ_RC6VIDS , &rc6vids);mutex_unlock (&dev->struct_mutex); seq_printf(m, "Video Turbo Mode: %s\n",@@ -1149,6 +1150,12 @@ static int gen6_drpc_info(struct seq_file *m)seq_printf (m,"RC6++ residency since boot: %u\n" ,I915_READ (GEN6_GT_GFX_RC6pp));drivers/gpu/drm/i915/i915_debugfs.c static int gen6_drpc_info(struct seq_file *m) · line 1161
Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +6
-0+seq_printf (m,"RC6 voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>0 ) &0xff ))); +seq_printf (m,"RC6+ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>8 ) &0xff ))); +seq_printf (m,"RC6++ voltage: %dmV\n" , +GEN6_DECODE_RC6_VID (((rc6vids >>16 ) &0xff )));return 0 ; }Nice.
Quoted 1 line
Reviewed-by Jesse Barnes <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 161 lines · On Wed, 26 Sep 2012 10:34:00 -0700 Ben Widawsky <[email protected]> wrote:
There is a special mechanism for communicating with the PCU already being used for the ring frequency stuff. As we'll be needing this for other commands, extract it now to make future code less error prone and the current code more reusable.
I'm not entirely sure if this code matches 1:1 with the previous code behaviorally. Functionally however, it should be the same.
CC Jesse Barnes <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 13 ++--- drivers/gpu/drm/i915/i915_drv.h | 3 ++ drivers/gpu/drm/i915/intel_pm.c | 94 +++++++++++++++++++++++-------------- 3 files changed, 67 insertions(+), 43 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-9@@ -1283,15 +1283,10 @@ static int i915_ring_freq_table(struct seq_file *m, void *unused)for (gpu_freq = dev_priv->rps.min_delay; gpu_freq <= dev_priv->rps.max_delay; gpu_freq++) { -I915_WRITE (GEN6_PCODE_DATA , gpu_freq); -I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_PCODE_READY | -GEN6_PCODE_READ_MIN_FREQ_TABLE ); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) & -GEN6_PCODE_READY ) ==0 ,10 )) { -DRM_ERROR ("pcode read of freq table timed out\n" ); -continue ; - } - ia_freq =I915_READ (GEN6_PCODE_DATA ); + ia_freq = gpu_freq; +sandybridge_pcode_read (dev_priv, +GEN6_PCODE_READ_MIN_FREQ_TABLE , + &ia_freq);seq_printf (m,"%d\t\t%d\n" , gpu_freq *GT_FREQUENCY_MULTIPLIER , ia_freq *100 ); }drivers/gpu/drm/i915/i915_drv.h +3
-0@@ -1622,6 +1622,9 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);void gen6_gt_force_wake_put (struct drm_i915_private *dev_priv);int __gen6_gt_wait_for_fifo (struct drm_i915_private *dev_priv); +int sandybridge_pcode_read (struct drm_i915_private *dev_priv,u8 mbox,u32 *val); +int sandybridge_pcode_write (struct drm_i915_private *dev_priv,u8 mbox,u32 val); +#define __i915_read (x, y) \ u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg);drivers/gpu/drm/i915/intel_pm.c +50
-34@@ -2503,30 +2503,16 @@ static void gen6_enable_rps(struct drm_device *dev)GEN6_RP_UP_BUSY_AVG | (IS_HASWELL(dev) ? GEN7_RP_DOWN_IDLE_AVG : GEN6_RP_DOWN_IDLE_CONT)); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , -500 )) -DRM_ERROR ("timeout waiting for pcode mailbox to become idle\n" ); - -I915_WRITE (GEN6_PCODE_DATA ,0 ); -I915_WRITE (GEN6_PCODE_MAILBOX , -GEN6_PCODE_READY | -GEN6_PCODE_WRITE_MIN_FREQ_TABLE ); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , -500 )) -DRM_ERROR ("timeout waiting for pcode mailbox to finish\n" ); - -/* Check for overclock support */ -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , -500 )) -DRM_ERROR ("timeout waiting for pcode mailbox to become idle\n" ); -I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_READ_OC_PARAMS ); - pcu_mbox =I915_READ (GEN6_PCODE_DATA ); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , -500 )) -DRM_ERROR ("timeout waiting for pcode mailbox to finish\n" ); -if (pcu_mbox & (1 <<31 )) {/* OC supported */ - dev_priv->rps.max_delay = pcu_mbox &0xff ; -DRM_DEBUG_DRIVER ("overclocking supported, adjusting frequency max to %dMHz\n" , pcu_mbox *50 ); + ret =sandybridge_pcode_write (dev_priv,GEN6_PCODE_WRITE_MIN_FREQ_TABLE ,0 ); +if (!ret) { + pcu_mbox =0 ; + ret =sandybridge_pcode_read (dev_priv,GEN6_READ_OC_PARAMS , &pcu_mbox); +if (ret && pcu_mbox & (1 <<31 )) {/* OC supported */ + dev_priv->rps.max_delay = pcu_mbox &0xff ; +DRM_DEBUG_DRIVER ("overclocking supported, adjusting frequency max to %dMHz\n" , pcu_mbox *50 ); + } + }else { +DRM_DEBUG_DRIVER ("Failed to set the min frequency\n" ); }gen6_set_rps (dev_priv->dev, (gt_perf_status &0xff00 ) >>8 );@@ -2581,17 +2567,11 @@ static void gen6_update_ring_freq(struct drm_device *dev)else ia_freq = max_ia_freq - ((diff * scaling_factor) /2 ); ia_freq =DIV_ROUND_CLOSEST (ia_freq,100 ); + ia_freq <<=GEN6_PCODE_FREQ_IA_RATIO_SHIFT ; -I915_WRITE (GEN6_PCODE_DATA , - (ia_freq <<GEN6_PCODE_FREQ_IA_RATIO_SHIFT ) | - gpu_freq); -I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_PCODE_READY | -GEN6_PCODE_WRITE_MIN_FREQ_TABLE ); -if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) & -GEN6_PCODE_READY ) ==0 ,10 )) { -DRM_ERROR ("pcode write of freq table timed out\n" ); -continue ; - } +sandybridge_pcode_write (dev_priv, +GEN6_PCODE_WRITE_MIN_FREQ_TABLE , + ia_freq | gpu_freq); } }@@ -4143,3 +4123,49 @@ void intel_gt_init(struct drm_device *dev) } } +int sandybridge_pcode_read (struct drm_i915_private *dev_priv,u8 mbox,u32 *val) +{ +WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex)); + +if (I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) { +DRM_DEBUG_DRIVER ("warning: pcode (read) mailbox access failed\n" ); +return -EAGAIN ; + } + +I915_WRITE (GEN6_PCODE_DATA , *val); +I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_PCODE_READY | mbox); + +if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , +500 )) { +DRM_ERROR ("timeout waiting for pcode read (%d) to finish\n" , mbox); +return -ETIMEDOUT ; + } + + *val =I915_READ (GEN6_PCODE_DATA ); +I915_WRITE (GEN6_PCODE_DATA ,0 ); + +return 0 ; +} + +int sandybridge_pcode_write (struct drm_i915_private *dev_priv,u8 mbox,u32 val) +{ +WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex)); + +if (I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) { +DRM_DEBUG_DRIVER ("warning: pcode (write) mailbox access failed\n" ); +return -EAGAIN ; + } + +I915_WRITE (GEN6_PCODE_DATA , val); +I915_WRITE (GEN6_PCODE_MAILBOX ,GEN6_PCODE_READY | mbox); +
drivers/gpu/drm/i915/intel_pm.c void intel_gt_init(struct drm_device *dev) · line 4171
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10
-0+if (wait_for ((I915_READ (GEN6_PCODE_MAILBOX ) &GEN6_PCODE_READY ) ==0 , +500 )) { +DRM_ERROR ("timeout waiting for pcode write (%d) to finish\n" , mbox); +return -ETIMEDOUT ; + } + +I915_WRITE (GEN6_PCODE_DATA ,0 ); + +return 0 ; +}
I'd call it punit rather than pcode, but that's just a nitpick. I like pulling it out into a separate function.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center