drm/i915: fix FORCEWAKE posting reads
Subsystems (2)
PATCH 1/1 drm/i915: fix FORCEWAKE posting reads
We stopped reading FORCEWAKE for posting reads in
commit 8dee3eea3ccd3b6c00a8d3a08dd715d6adf737dd
Author: Ben Widawsky <[email protected]> Date: Sat Sep 1 22:59:50 2012 -0700
drm/i915: Never read FORCEWAKE
and started using something from the same cacheline instead. This was true for ECOBUS, but not for GTFIFODBG. Add posting reads on ECOBUS where GTFIFODBG was relied on.
In true cargo cult spirit, add posting reads for FORCEWAKE_VLV writes as well.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52411
--- drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +12 -5
@@ -4122,7 +4122,8 @@ static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_mt_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (0xffff )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS ); }static void __gen6_gt_force_wake_mt_get (struct drm_i915_private *dev_priv)
@@ -4139,7 +4140,8 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)DRM_ERROR ("Timed out waiting for forcewake old ack to clear.\n" );I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_ENABLE (FORCEWAKE_KERNEL )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );if (wait_for_atomic ((I915_READ_NOTRACE (forcewake_ack) &1 ),FORCEWAKE_ACK_TIMEOUT_MS ))
@@ -4176,14 +4178,16 @@ void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE ,0 ); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }static void __gen6_gt_force_wake_mt_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }
@@ -4223,6 +4227,8 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)static void vlv_force_wake_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (0xffff )); +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV ); }static void vlv_force_wake_get (struct drm_i915_private *dev_priv)
@@ -4243,7 +4249,8 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)static void vlv_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* The below doubles as a POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV );gen6_gt_check_fifodbg (dev_priv); }
Signature · 1 line
1.7.9.5
Quoted 12 lines · Jani Nikula
We stopped reading FORCEWAKE for posting reads in
commit
8dee3eea3ccd3b6c00a8d3a08dd715d6adf737ddAuthor: Ben Widawsky <[email protected]> Date: Sat Sep 1 22:59:50 2012 -0700drm/i915: Never read FORCEWAKE
and started using something from the same cacheline instead. This was true for ECOBUS, but not for GTFIFODBG. Add posting reads on ECOBUS where GTFIFODBG was relied on.
Quoted 7 lines
In true cargo cult spirit, add posting reads for
FORCEWAKE_VLVwrites as well.Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52411
Reported-and-tested-by Alexander Bersenev <[email protected]>CC Ben Widawsky <[email protected]>Signed-off-by Jani Nikula <[email protected]>
Am I the only skeptic about what is actually fixing the bug here? Without WC MMIO, the cacheline we readback from makes no difference.
ie. I put ECOBUS there for a warm and fuzzy feeling, nothing else.
Quoted 69 lines
--- drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_pm.c +12
-5@@ -4122,7 +4122,8 @@ static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_mt_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (0xffff )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS ); }static void __gen6_gt_force_wake_mt_get (struct drm_i915_private *dev_priv)@@ -4139,7 +4140,8 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)DRM_ERROR ("Timed out waiting for forcewake old ack to clear.\n" );I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_ENABLE (FORCEWAKE_KERNEL )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );if (wait_for_atomic ((I915_READ_NOTRACE (forcewake_ack) &1 ),FORCEWAKE_ACK_TIMEOUT_MS ))@@ -4176,14 +4178,16 @@ void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE ,0 ); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }static void __gen6_gt_force_wake_mt_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }@@ -4223,6 +4227,8 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)static void vlv_force_wake_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (0xffff )); +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV ); }static void vlv_force_wake_get (struct drm_i915_private *dev_priv)@@ -4243,7 +4249,8 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)static void vlv_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* The below doubles as a POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV );gen6_gt_check_fifodbg (dev_priv); }Signature · 1 line
1.7.9.5
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH v2 1/1 drm/i915: fix FORCEWAKE posting reads
We stopped reading FORCEWAKE for posting reads in
commit 8dee3eea3ccd3b6c00a8d3a08dd715d6adf737dd
Author: Ben Widawsky <[email protected]> Date: Sat Sep 1 22:59:50 2012 -0700
drm/i915: Never read FORCEWAKE
and started using something from the same cacheline instead. It turns out reading ECOBUS as posting read worked fine, while GTFIFODBG did not, preventing RC6 states after suspend/resume per the bug report referenced below. It's not entirely clear why, but clearly GTFIFODBG was nowhere near the same cacheline or address range as FORCEWAKE.
Trying out various registers for posting reads showed that all tested registers for which NEEDS_FORCE_WAKE() (in i915_drv.c) returns true work. Conversely, most (but not quite all) registers for which NEEDS_FORCE_WAKE() returns false do not work. Details in the referenced bug.
Based on the above, add posting reads on ECOBUS where GTFIFODBG was previously relied on.
In true cargo cult spirit, add posting reads for FORCEWAKE_VLV writes as well, but instead of ECOBUS, use FORCEWAKE_ACK_VLV which is in the same address range as FORCEWAKE_VLV.
v2: Add more details to the commit message. No functional changes.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52411
--- drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +12 -5
@@ -4122,7 +4122,8 @@ static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_mt_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (0xffff )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS ); }static void __gen6_gt_force_wake_mt_get (struct drm_i915_private *dev_priv)
@@ -4139,7 +4140,8 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)DRM_ERROR ("Timed out waiting for forcewake old ack to clear.\n" );I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_ENABLE (FORCEWAKE_KERNEL )); -POSTING_READ (ECOBUS );/* something from same cacheline, but !FORCEWAKE */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );if (wait_for_atomic ((I915_READ_NOTRACE (forcewake_ack) &1 ),FORCEWAKE_ACK_TIMEOUT_MS ))
@@ -4176,14 +4178,16 @@ void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv)static void __gen6_gt_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE ,0 ); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }static void __gen6_gt_force_wake_mt_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_MT ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* gen6_gt_check_fifodbg doubles as the POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_MT */ +POSTING_READ (ECOBUS );gen6_gt_check_fifodbg (dev_priv); }
@@ -4223,6 +4227,8 @@ int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)static void vlv_force_wake_reset (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (0xffff )); +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV ); }static void vlv_force_wake_get (struct drm_i915_private *dev_priv)
@@ -4243,7 +4249,8 @@ static void vlv_force_wake_get(struct drm_i915_private *dev_priv)static void vlv_force_wake_put (struct drm_i915_private *dev_priv) {I915_WRITE_NOTRACE (FORCEWAKE_VLV ,_MASKED_BIT_DISABLE (FORCEWAKE_KERNEL )); -/* The below doubles as a POSTING_READ */ +/* something from same cacheline, but !FORCEWAKE_VLV */ +POSTING_READ (FORCEWAKE_ACK_VLV );gen6_gt_check_fifodbg (dev_priv); }
Signature · 1 line
1.7.9.5
Quoted 27 lines · Jani Nikula
We stopped reading FORCEWAKE for posting reads in
commit
8dee3eea3ccd3b6c00a8d3a08dd715d6adf737ddAuthor: Ben Widawsky <[email protected]> Date: Sat Sep 1 22:59:50 2012 -0700drm/i915: Never read FORCEWAKE
and started using something from the same cacheline instead. It turns out reading ECOBUS as posting read worked fine, while GTFIFODBG did not, preventing RC6 states after suspend/resume per the bug report referenced below. It's not entirely clear why, but clearly GTFIFODBG was nowhere near the same cacheline or address range as FORCEWAKE.
Trying out various registers for posting reads showed that all tested registers for which
NEEDS_FORCE_WAKE()(ini915_drv.c) returns true work. Conversely, most (but not quite all) registers for whichNEEDS_FORCE_WAKE()returns false do not work. Details in the referenced bug.Based on the above, add posting reads on ECOBUS where GTFIFODBG was previously relied on.
In true cargo cult spirit, add posting reads for
FORCEWAKE_VLVwrites as well, but instead of ECOBUS, useFORCEWAKE_ACK_VLVwhich is in the same address range asFORCEWAKE_VLV.
Quoted 6 lines
v2: Add more details to the commit message. No functional changes.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52411
Reported-and-tested-by Alexander Bersenev <[email protected]>CC Ben Widawsky <[email protected]>Signed-off-by Jani Nikula <[email protected]>
You don't mention at all why you consider this to be important at all. A hint that the extra read makes rc6 after resume more stable on one machine would be useful.
So a missing flush of the write in _put() makes sense for rc6 staying active. (If it happens once, it can happen everytime we do the forcewake dance and so stay asserted indefinitely). And I can quite believe that the hw has separate queues for the GT powerwell that require a read from within that powerwell to flush, so the magic pixie dust looks consistent.
Ok, I'm happy that I can rationalise that this does indeed fix a genuine quirk of our hw. The cargo cult survives.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 39 lines · Chris Wilson
Quoted 27 lines · Jani Nikula
We stopped reading FORCEWAKE for posting reads in
commit
8dee3eea3ccd3b6c00a8d3a08dd715d6adf737ddAuthor: Ben Widawsky <[email protected]> Date: Sat Sep 1 22:59:50 2012 -0700drm/i915: Never read FORCEWAKE
and started using something from the same cacheline instead. It turns out reading ECOBUS as posting read worked fine, while GTFIFODBG did not, preventing RC6 states after suspend/resume per the bug report referenced below. It's not entirely clear why, but clearly GTFIFODBG was nowhere near the same cacheline or address range as FORCEWAKE.
Trying out various registers for posting reads showed that all tested registers for which
NEEDS_FORCE_WAKE()(ini915_drv.c) returns true work. Conversely, most (but not quite all) registers for whichNEEDS_FORCE_WAKE()returns false do not work. Details in the referenced bug.Based on the above, add posting reads on ECOBUS where GTFIFODBG was previously relied on.
In true cargo cult spirit, add posting reads for
FORCEWAKE_VLVwrites as well, but instead of ECOBUS, useFORCEWAKE_ACK_VLVwhich is in the same address range asFORCEWAKE_VLV.Quoted 6 lines
v2: Add more details to the commit message. No functional changes.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52411
Reported-and-tested-by Alexander Bersenev <[email protected]>CC Ben Widawsky <[email protected]>Signed-off-by Jani Nikula <[email protected]>You don't mention at all why you consider this to be important at all. A hint that the extra read makes rc6 after resume more stable on one machine would be useful.
Quoted 8 lines
So a missing flush of the write in
_put()makes sense for rc6 staying active. (If it happens once, it can happen everytime we do the forcewake dance and so stay asserted indefinitely). And I can quite believe that the hw has separate queues for the GT powerwell that require a read from within that powerwell to flush, so the magic pixie dust looks consistent.Ok, I'm happy that I can rationalise that this does indeed fix a genuine quirk of our hw. The cargo cult survives.
Right, I just didn't feel very confident making strong claims here based on more or less anecdotal evidence. (And even the original "never read FORCEWAKE" feels like folklore...) Making rc6 more stable on one machine was implied, but I could have been more explict about it. Perhaps Daniel can amend the commit message from the above as he sees fit?
Thanks for the review.
BR,
Jani.
Quoted 6 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 5 lines · Jani Nikula
Right, I just didn't feel very confident making strong claims here based on more or less anecdotal evidence. (And even the original "never read FORCEWAKE" feels like folklore...) Making rc6 more stable on one machine was implied, but I could have been more explict about it. Perhaps Daniel can amend the commit message from the above as he sees fit?
Merged and amended slightly to make it clear that it fixes a regression, and what the exact nature of the regression was. Also added cc: stable. Thanks for patch and review.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch