diff mbox

[1/4] drm/i915: Fix false-positive assert_rpm_wakelock_held in i915_pmic_bus_access_notifier

Message ID 20170519132704.25527-1-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans de Goede May 19, 2017, 1:27 p.m. UTC
assert_rpm_wakelock_held is triggered from i915_pmic_bus_access_notifier
even though it gets unregistered on (runtime) suspend, this is caused
by a race happening under the following circumstances:

intel_runtime_pm_put does:

   atomic_dec(&dev_priv->pm.wakeref_count);

   pm_runtime_mark_last_busy(kdev);
   pm_runtime_put_autosuspend(kdev);

And pm_runtime_put_autosuspend calls intel_runtime_suspend from
a workqueue, so there is ample of time between the atomic_dec() and
intel_runtime_suspend() unregistering the notifier. If the notifier
gets called in this windowd assert_rpm_wakelock_held falsely triggers
(at this point we're not runtime-suspended yet).

This commit adds disable_rpm_wakeref_asserts and
enable_rpm_wakeref_asserts calls around the
intel_uncore_forcewake_get(FORCEWAKE_ALL) call in
i915_pmic_bus_access_notifier fixing the false-positive WARN_ON.

Reported-by: FKr <bugs-freedesktop@ubermail.me>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/i915/intel_uncore.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Hans de Goede May 28, 2017, 2:05 p.m. UTC | #1
Hi,

On 19-05-17 15:27, Hans de Goede wrote:
> assert_rpm_wakelock_held is triggered from i915_pmic_bus_access_notifier
> even though it gets unregistered on (runtime) suspend, this is caused
> by a race happening under the following circumstances:
> 
> intel_runtime_pm_put does:
> 
>     atomic_dec(&dev_priv->pm.wakeref_count);
> 
>     pm_runtime_mark_last_busy(kdev);
>     pm_runtime_put_autosuspend(kdev);
> 
> And pm_runtime_put_autosuspend calls intel_runtime_suspend from
> a workqueue, so there is ample of time between the atomic_dec() and
> intel_runtime_suspend() unregistering the notifier. If the notifier
> gets called in this windowd assert_rpm_wakelock_held falsely triggers
> (at this point we're not runtime-suspended yet).
> 
> This commit adds disable_rpm_wakeref_asserts and
> enable_rpm_wakeref_asserts calls around the
> intel_uncore_forcewake_get(FORCEWAKE_ALL) call in
> i915_pmic_bus_access_notifier fixing the false-positive WARN_ON.
> 
> Reported-by: FKr <bugs-freedesktop@ubermail.me>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Ping, what is the status of this series?

I've been running this series on several Bay and Cherry Trail devices
since I posted this without issues.

As this fixes a couple of corner case wrt the pmic bus access
sharing merged for 4.12, it would be nice to get these
queued up and of possible added to a 4.12-rc#.

The only patch which changes code / functionality which was present
in 4.11 is the 3th patch, which I added because Ville requested the
change. The other 3 can be queued up for 4.12 without the 3th patch.

Regards,

Hans



> ---
>   drivers/gpu/drm/i915/intel_uncore.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 6d1ea26b2493..dc5e4f3e5a43 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1286,8 +1286,15 @@ static int i915_pmic_bus_access_notifier(struct notifier_block *nb,
>   		 * bus, which will be busy after this notification, leading to:
>   		 * "render: timed out waiting for forcewake ack request."
>   		 * errors.
> +		 *
> +		 * This notifier may get called between intel_runtime_pm_put()
> +		 * doing atomic_dec(wakeref_count) and intel_runtime_resume()
> +		 * unregistering this notifier, which leads to false-positive
> +		 * assert_rpm_wakelock_held() triggering.
>   		 */
> +		disable_rpm_wakeref_asserts(dev_priv);
>   		intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
> +		enable_rpm_wakeref_asserts(dev_priv);
>   		break;
>   	case MBI_PMIC_BUS_ACCESS_END:
>   		intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 6d1ea26b2493..dc5e4f3e5a43 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1286,8 +1286,15 @@  static int i915_pmic_bus_access_notifier(struct notifier_block *nb,
 		 * bus, which will be busy after this notification, leading to:
 		 * "render: timed out waiting for forcewake ack request."
 		 * errors.
+		 *
+		 * This notifier may get called between intel_runtime_pm_put()
+		 * doing atomic_dec(wakeref_count) and intel_runtime_resume()
+		 * unregistering this notifier, which leads to false-positive
+		 * assert_rpm_wakelock_held() triggering.
 		 */
+		disable_rpm_wakeref_asserts(dev_priv);
 		intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+		enable_rpm_wakeref_asserts(dev_priv);
 		break;
 	case MBI_PMIC_BUS_ACCESS_END:
 		intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);