mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 04:46:32 +07:00
drm/i915: Convert sandybridge_pcode_*() to use intel_wait_for_register()
We want to replace the inline wait_for() with an out-of-line hybrid busy/sleep wait_for() in the hopes of speeding up the communication wit the PCode unit. Indeed, on my i5-2500s, __gen6_update_ring_freq improves from 6,080,661ns to 8172ns. v2: Missed using _fw variants for sandybridge_pcode_read() Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1467297225-21379-2-git-send-email-chris@chris-wilson.co.uk
This commit is contained in:
parent
1758b90e38
commit
3f5582dd84
@ -7623,46 +7623,59 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val
|
|||||||
{
|
{
|
||||||
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
|
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
|
||||||
|
|
||||||
if (I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
|
/* GEN6_PCODE_* are outside of the forcewake domain, we can
|
||||||
|
* use te fw I915_READ variants to reduce the amount of work
|
||||||
|
* required when reading/writing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
|
||||||
DRM_DEBUG_DRIVER("warning: pcode (read) mailbox access failed\n");
|
DRM_DEBUG_DRIVER("warning: pcode (read) mailbox access failed\n");
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
I915_WRITE(GEN6_PCODE_DATA, *val);
|
I915_WRITE_FW(GEN6_PCODE_DATA, *val);
|
||||||
I915_WRITE(GEN6_PCODE_DATA1, 0);
|
I915_WRITE_FW(GEN6_PCODE_DATA1, 0);
|
||||||
I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
|
I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
|
||||||
|
|
||||||
if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
|
if (intel_wait_for_register_fw(dev_priv,
|
||||||
500)) {
|
GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0,
|
||||||
|
500)) {
|
||||||
DRM_ERROR("timeout waiting for pcode read (%d) to finish\n", mbox);
|
DRM_ERROR("timeout waiting for pcode read (%d) to finish\n", mbox);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = I915_READ(GEN6_PCODE_DATA);
|
*val = I915_READ_FW(GEN6_PCODE_DATA);
|
||||||
I915_WRITE(GEN6_PCODE_DATA, 0);
|
I915_WRITE_FW(GEN6_PCODE_DATA, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sandybridge_pcode_write(struct drm_i915_private *dev_priv, u32 mbox, u32 val)
|
int sandybridge_pcode_write(struct drm_i915_private *dev_priv,
|
||||||
|
u32 mbox, u32 val)
|
||||||
{
|
{
|
||||||
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
|
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
|
||||||
|
|
||||||
if (I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
|
/* GEN6_PCODE_* are outside of the forcewake domain, we can
|
||||||
|
* use te fw I915_READ variants to reduce the amount of work
|
||||||
|
* required when reading/writing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
|
||||||
DRM_DEBUG_DRIVER("warning: pcode (write) mailbox access failed\n");
|
DRM_DEBUG_DRIVER("warning: pcode (write) mailbox access failed\n");
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
I915_WRITE(GEN6_PCODE_DATA, val);
|
I915_WRITE_FW(GEN6_PCODE_DATA, val);
|
||||||
I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
|
I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
|
||||||
|
|
||||||
if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
|
if (intel_wait_for_register_fw(dev_priv,
|
||||||
500)) {
|
GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0,
|
||||||
|
500)) {
|
||||||
DRM_ERROR("timeout waiting for pcode write (%d) to finish\n", mbox);
|
DRM_ERROR("timeout waiting for pcode write (%d) to finish\n", mbox);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
I915_WRITE(GEN6_PCODE_DATA, 0);
|
I915_WRITE_FW(GEN6_PCODE_DATA, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user