drm/i915: improve the RPM device suspended assert
Subsystems (2)
cover drm/i915: improve the RPM device suspended assert
Motivated by the discussions with Chris about imrpoving our RPM ref get/put logic and seeing that we are still missing RPM refs from places I improved a bit the assert that checks if the device is powered on while we are accessing the HW. This produced at least one additional assert on the atomic commit path, so I think it's useful.
This is based on Patrik's DC rework patches [1], but just to avoid merge conflicts, functionally it doesn't depend on that.
Tested on SKL.
[1]
http://lists.freedesktop.org/archives/intel-gfx/2015-November/079758.html
Imre Deak (4):
drm/i915: export assert_device_not_suspended
drm/i915: use assert_device_not_suspended instead of opencoding it drm/i915: make assert_device_not_suspended more precise drm/i915: add assert_device_not_suspended to GGTT PTE updaters
drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++ drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_runtime_pm.c | 26 ++++++++++++++++++++------ drivers/gpu/drm/i915/intel_uncore.c | 9 +-------- 6 files changed, 41 insertions(+), 14 deletions(-)
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/4 drm/i915: export assert_device_not_suspended
We should use the same assert in more places, so export it. Move it to intel_runtime_pm.c at the same time, since that's a more logical place for it.
--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_runtime_pm.c | 6 ++++++ drivers/gpu/drm/i915/intel_uncore.c | 7 ------- 3 files changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -1415,6 +1415,8 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain);void intel_display_power_put (struct drm_i915_private *dev_priv,enum intel_display_power_domain domain); + +void assert_device_not_suspended (struct drm_i915_private *dev_priv);void intel_runtime_pm_get (struct drm_i915_private *dev_priv);void intel_runtime_pm_get_noresume (struct drm_i915_private *dev_priv);void intel_runtime_pm_put (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_runtime_pm.c +6 -0
@@ -2120,6 +2120,12 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) power_domains->initializing = false; } +void assert_device_not_suspended (struct drm_i915_private *dev_priv) +{ +WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, +"Device suspended\n" ); +} +/** * intel_power_domains_suspend - suspend power domain state * @dev_priv: i915 device instance
drivers/gpu/drm/i915/intel_uncore.c +0 -7
@@ -50,13 +50,6 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)return "unknown" ; } -static void -assert_device_not_suspended (struct drm_i915_private *dev_priv) -{ -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" ); -} -static inline void fw_domain_reset (const struct intel_uncore_forcewake_domain *d) {
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/4] drm/i915: export assert_device_not_suspended
Quoted 29 lines · Imre Deak
We should use the same assert in more places, so export it. Move it to
intel_runtime_pm.cat the same time, since that's a more logical place for it.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_runtime_pm.c | 6 ++++++ drivers/gpu/drm/i915/intel_uncore.c | 7 ------- 3 files changed, 8 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -1415,6 +1415,8 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain);void intel_display_power_put (struct drm_i915_private *dev_priv,enum intel_display_power_domain domain); + +void assert_device_not_suspended (struct drm_i915_private *dev_priv);void intel_runtime_pm_get (struct drm_i915_private *dev_priv);void intel_runtime_pm_get_noresume (struct drm_i915_private *dev_priv);void intel_runtime_pm_put (struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) · line 2125
Quoted 6 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0@@ -2120,6 +2120,12 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) power_domains->initializing = false; } +void assert_device_not_suspended (struct drm_i915_private *dev_priv) +{ + WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv->pm.suspended,
Is there any point in the HAS_RUNTIME_PM() check?
Quoted 31 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0+ "Device suspended\n"); +} +/** * intel_power_domains_suspend - suspend power domain state * @dev_priv: i915 device instance drivers/gpu/drm/i915/intel_uncore.c +0
-7@@ -50,13 +50,6 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)return "unknown" ; } -static void -assert_device_not_suspended (struct drm_i915_private *dev_priv) -{ -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" ); -} -static inline void fw_domain_reset (const struct intel_uncore_forcewake_domain *d) {Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/4] drm/i915: export assert_device_not_suspended
Quoted 43 lines · Ville Syrjälä
Quoted 42 lines · Imre Deak
We should use the same assert in more places, so export it. Move it to
intel_runtime_pm.cat the same time, since that's a more logical place
for it.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_runtime_pm.c | 6 ++++++ drivers/gpu/drm/i915/intel_uncore.c | 7 ------- 3 files changed, 8 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -1415,6 +1415,8 @@ void intel_display_power_get(structdrm_i915_private *dev_priv, enum intel_display_power_domain domain);void intel_display_power_put (struct drm_i915_private *dev_priv,enum intel_display_power_domain domain); + +void assert_device_not_suspended(struct drm_i915_private
*dev_priv);
voidintel_runtime_pm_get(struct drm_i915_private *dev_priv); void intel_runtime_pm_get_noresume(structdrm_i915_private*dev_priv);
voidintel_runtime_pm_put(struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -2120,6 +2120,12 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) power_domains->initializing = false; }
Quoted 7 lines
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_init_hw(struct · line 2125
Quoted 5 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-1+void assert_device_not_suspended (struct drm_i915_private *dev_priv) +{ + WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv ->pm.suspended,Is there any point in the
HAS_RUNTIME_PM()check?
All other platforms should have pm.suspended = false and a non-zero refcount all the time, so I guess not. I can remove it in patch 3/4.
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0+ "Device suspended\n"); +} +/** * intel_power_domains_suspend - suspend power domain state * @dev_priv: i915 device instance drivers/gpu/drm/i915/intel_uncore.c +0
-8@@ -50,13 +50,6 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)return "unknown" ; } -static void -assert_device_not_suspended (struct drm_i915_private *dev_priv) -{ -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv ->pm.suspended, -"Device suspended\n" ); -} -static inline void fw_domain_reset (const struct intel_uncore_forcewake_domain *d) {Signature · 1 line
2.5.0
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/4] drm/i915: export assert_device_not_suspended
In reply to Imre DeakQuoted 29 lines · Imre Deak
We should use the same assert in more places, so export it. Move it to
intel_runtime_pm.cat the same time, since that's a more logical place for it.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_runtime_pm.c | 6 ++++++ drivers/gpu/drm/i915/intel_uncore.c | 7 ------- 3 files changed, 8 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -1415,6 +1415,8 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain);void intel_display_power_put (struct drm_i915_private *dev_priv,enum intel_display_power_domain domain); + +void assert_device_not_suspended (struct drm_i915_private *dev_priv);void intel_runtime_pm_get (struct drm_i915_private *dev_priv);void intel_runtime_pm_get_noresume (struct drm_i915_private *dev_priv);void intel_runtime_pm_put (struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) · line 2125
Quoted 6 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0@@ -2120,6 +2120,12 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) power_domains->initializing = false; } +void assert_device_not_suspended (struct drm_i915_private *dev_priv) +{ + WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv->pm.suspended,
Can just be HAS_RUNTIME_PM(dev_priv).
Can we fix HAS_RUNTIME_PM not to be an ever-growing list but a nice little feature flag?
{
if (!HAS_RUNTIME_PM(dev_priv))
return;
WARN_ONCE(dev_priv->pm.suspended, "Device suspended during HW access");
}
The little extra information would be nice in the error message, but not convinced the extra whitespace is that helpful.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: use assert_device_not_suspended instead of opencoding it
In reply to Imre Deak--- drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++------ drivers/gpu/drm/i915/intel_uncore.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +4 -6
@@ -464,8 +464,7 @@ static void assert_can_enable_dc5(struct drm_i915_private *dev_priv)WARN_ONCE ((I915_READ (DC_STATE_EN ) &DC_STATE_EN_UPTO_DC5 ),"DC5 already programmed to be enabled.\n" ); -WARN_ONCE (dev_priv->pm.suspended, -"DC5 cannot be enabled, if platform is runtime-suspended.\n" ); +assert_device_not_suspended (dev_priv);assert_csr_loaded (dev_priv); }
@@ -479,8 +478,7 @@ static void assert_can_disable_dc5(struct drm_i915_private *dev_priv)if (dev_priv->power_domains.initializing)return ; -WARN_ONCE (dev_priv->pm.suspended, -"Disabling of DC5 while platform is runtime-suspended should never happen.\n" ); +assert_device_not_suspended (dev_priv); }static void gen9_enable_dc5 (struct drm_i915_private *dev_priv)
@@ -2158,7 +2156,7 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)return ;pm_runtime_get_sync (device); -WARN (dev_priv->pm.suspended,"Device still suspended.\n" ); +assert_device_not_suspended (dev_priv); }/**
@@ -2186,7 +2184,7 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)if (!HAS_RUNTIME_PM (dev))return ; -WARN (dev_priv->pm.suspended,"Getting nosync-ref while suspended.\n" ); +assert_device_not_suspended (dev_priv);pm_runtime_get_noresume (device); }
drivers/gpu/drm/i915/intel_uncore.c +1 -1
@@ -404,7 +404,7 @@ void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv,if (!dev_priv->uncore.funcs.force_wake_get)return ; -WARN_ON (dev_priv->pm.suspended); +assert_device_not_suspended (dev_priv);spin_lock_irqsave (&dev_priv->uncore.lock, irqflags);__intel_uncore_forcewake_get (dev_priv, fw_domains);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/4] drm/i915: use assert_device_not_suspended instead of opencoding it
Quoted 1 line · Imre Deak
Signed-off-by Imre Deak <[email protected]>
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: make assert_device_not_suspended more precise
In reply to Imre DeakAtm, we assert that the device is not suspended after the point when the HW is truly put to a suspended state. This is fine, but we can catch more problems if we check the RPM refcount. After that one drops to zero we shouldn't access the HW any more, although the actual suspend may be delayed. The only complication is that we want to avoid asserts while the suspend handler itself is running, so add a flag to handle this case.
This caught additional WARNs from the atomic path, those will be fixed as a follow-up.
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1494,6 +1494,9 @@ static int intel_runtime_suspend(struct device *device)return -EAGAIN ; } + + dev_priv->pm.disable_suspended_assert = true; +/* * We are safe here against re-faults, since the fault handler takes * an RPM reference.
@@ -1518,6 +1521,8 @@ static int intel_runtime_suspend(struct device *device)intel_uncore_forcewake_reset (dev, false); dev_priv->pm.suspended = true; + dev_priv->pm.disable_suspended_assert = false; +/* * FIXME: We really should find a document that references the arguments * used below!
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -1599,6 +1599,11 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +/* +* Used for the duration of runtime suspend to avoid false device +* suspended asserts. +*/ +bool disable_suspended_assert;bool suspended;bool irqs_enabled; };
drivers/gpu/drm/i915/intel_runtime_pm.c +12 -2
@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)void assert_device_not_suspended (struct drm_i915_private *dev_priv) { -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" ); +int rpm_usage; + +if (!HAS_RUNTIME_PM (dev_priv) || dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage =atomic_read (&dev_priv->dev->dev->power.usage_count); +#else + rpm_usage =1 ; +#endif + +WARN_ONCE (dev_priv->pm.suspended || !rpm_usage,"Device suspended\n" ); }/**
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/4 drm/i915: make assert_device_not_suspended more precise
Atm, we assert that the device is not suspended after the point when the HW is truly put to a suspended state. This is fine, but we can catch more problems if we check the RPM refcount. After that one drops to zero we shouldn't access the HW any more, although the actual suspend may be delayed. The only complication is that we want to avoid asserts while the suspend handler itself is running, so add a flag to handle this case.
While at it remove the HAS_RUNTIME_PM check, the pm.suspended flag is false and the RPM refcount is non-zero on all platforms that don't support RPM.
This caught additional WARNs from the atomic path, those will be fixed as a follow-up.
v2:
- remove the redundant HAS_RUNTIME_PM check (Ville)
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1494,6 +1494,9 @@ static int intel_runtime_suspend(struct device *device)return -EAGAIN ; } + + dev_priv->pm.disable_suspended_assert = true; +/* * We are safe here against re-faults, since the fault handler takes * an RPM reference.
@@ -1518,6 +1521,8 @@ static int intel_runtime_suspend(struct device *device)intel_uncore_forcewake_reset (dev, false); dev_priv->pm.suspended = true; + dev_priv->pm.disable_suspended_assert = false; +/* * FIXME: We really should find a document that references the arguments * used below!
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -1599,6 +1599,11 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +/* +* Used for the duration of runtime suspend to avoid false device +* suspended asserts. +*/ +bool disable_suspended_assert;bool suspended;bool irqs_enabled; };
drivers/gpu/drm/i915/intel_runtime_pm.c +12 -2
@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)void assert_device_not_suspended (struct drm_i915_private *dev_priv) { -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" ); +int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage =atomic_read (&dev_priv->dev->dev->power.usage_count); +#else + rpm_usage =1 ; +#endif + +WARN_ONCE (dev_priv->pm.suspended || !rpm_usage,"Device suspended\n" ); }/**
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 28 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the HW is truly put to a suspended state. This is fine, but we can catch more problems if we check the RPM refcount. After that one drops to zero we shouldn't access the HW any more, although the actual suspend may be delayed. The only complication is that we want to avoid asserts while the suspend handler itself is running, so add a flag to handle this case.
While at it remove the
HAS_RUNTIME_PMcheck, the pm.suspended flag is false and the RPM refcount is non-zero on all platforms that don't support RPM.This caught additional WARNs from the atomic path, those will be fixed as a follow-up.
v2:
- remove the redundantHAS_RUNTIME_PMcheck (Ville)Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c +0
-2@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)void assert_device_not_suspended (struct drm_i915_private *dev_priv) { -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" );
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) · line 2132
Quoted 10 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +10
-0+int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage =atomic_read (&dev_priv->dev->dev->power.usage_count); +#else + rpm_usage =1 ; +#endif
Whilst this should fix the issue I was worried about, I think for e.g. the GGTT PTE access, we should be checking that we have a rpm ref (i.e. we have called intel_runtime_pm_get()). Bonus points if we can narrow that down to being inside an rpm critical section (made tricky because the wakelocks can nest :(. The simplest way does impose an extra atomic inc/dec simply for debug purposes, on the other hand it shouldn't then need the pm.disable_suspended_assert and you can have an extra assert that we cannot set pm.suspended whilst intel_runtime_pm_get() is held.
Otherwise, yeah just rename this to imply we aren't just checking that the device isn't suspended right now, but cannot be.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 48 lines · Chris Wilson
Quoted 47 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catch
more problems if we check the RPM refcount. After that one drops to zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this case.While at it remove the
HAS_RUNTIME_PMcheck, the pm.suspended flag is
false and the RPM refcount is non-zero on all platforms that don't support RPM.This caught additional WARNs from the atomic path, those will be fixed
as a follow-up.v2:
- remove the redundantHAS_RUNTIME_PMcheck (Ville)Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c +8
-4@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) void assert_device_not_suspended(struct drm_i915_private *dev_priv) { - WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv ->pm.suspended, - "Device suspended\n"); + int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage = atomic_read(&dev_priv->dev->dev ->power.usage_count); +#else
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) · line 2132
Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+ rpm_usage =1 ; +#endif Whilst this should fix the issue I was worried about, I think for e.g.
the GGTT PTE access, we should be checking that we have a rpm ref (i.e.
we have calledintel_runtime_pm_get()).
Right, didn't think of that. Also we don't have to then to access RPM internals.
Quoted 10 lines
Bonus points if we can narrow
that down to being inside an rpm critical section (made tricky because
the wakelocks can nest :(. The simplest way does impose an extra atomic
inc/dec simply for debug purposes, on the other hand it shouldn't then
need the pm.disable_suspended_assert and you can have an extra assert that we cannot set pm.suspended whilstintel_runtime_pm_get()is held.
Ok, this was interesting and made me look at the current users of RPM. We have two distinct use cases with different semantics: one in which we take an RPM ref for a prolonged time and not necessarily release it in the same context (thread). For example while the GT or any display outputs are active. The other scenario is for short tasks like programming the GGTT PTE, or anything else where we wrap something between a get and a put in the same context. In this case the ref will be released from the same context as where it was taken. These two use cases are worth making explicit in the API imo, both for documentation and for additional sanity checking: in the prolonged case we can only check for the refcount not to get unbalanced globally (since the get and put can happen in different contexts). In the case we take the ref for a short time we can additionally check for the critical section guarantee, plus that there is no inbalance from each context's POV. All of these additional checks can be provided by lockdep.
Quoted 1 line
Otherwise, yeah just rename this to imply we aren't just checking
that
Quoted 1 line
the device isn't suspended right now, but cannot be.
Ok, I put all the fixes for the review comments so far and the lockdep thing on top to:
https://github.com/ideak/linux/commits/rpm-assert-improvements
I can post these if there are no objections.
--Imre
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
In reply to Imre DeakQuoted 7 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the HW is truly put to a suspended state. This is fine, but we can catch more problems if we check the RPM refcount. After that one drops to zero we shouldn't access the HW any more, although the actual suspend may be delayed. The only complication is that we want to avoid asserts while the suspend handler itself is running, so add a flag to handle this case.
Why do we want to avoid asserts firing while we go through the suspend handler? Calling assert_device_not_suspended from within rpm suspend/resume code sounds like a bug. Where/why does this happen? -Daniel
Quoted 89 lines
While at it remove the
HAS_RUNTIME_PMcheck, the pm.suspended flag is false and the RPM refcount is non-zero on all platforms that don't support RPM.This caught additional WARNs from the atomic path, those will be fixed as a follow-up.
v2:
- remove the redundantHAS_RUNTIME_PMcheck (Ville)Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_drv.c +5
-0@@ -1494,6 +1494,9 @@ static int intel_runtime_suspend(struct device *device)return -EAGAIN ; } + + dev_priv->pm.disable_suspended_assert = true; +/* * We are safe here against re-faults, since the fault handler takes * an RPM reference. @@ -1518,6 +1521,8 @@ static int intel_runtime_suspend(struct device *device)intel_uncore_forcewake_reset (dev, false); dev_priv->pm.suspended = true; + dev_priv->pm.disable_suspended_assert = false; +/* * FIXME: We really should find a document that references the arguments * used below! drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -1599,6 +1599,11 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +/* +* Used for the duration of runtime suspend to avoid false device +* suspended asserts. +*/ +bool disable_suspended_assert;bool suspended;bool irqs_enabled; };drivers/gpu/drm/i915/intel_runtime_pm.c +12
-2@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)void assert_device_not_suspended (struct drm_i915_private *dev_priv) { -WARN_ONCE (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, -"Device suspended\n" ); +int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage =atomic_read (&dev_priv->dev->dev->power.usage_count); +#else + rpm_usage =1 ; +#endif + +WARN_ONCE (dev_priv->pm.suspended || !rpm_usage,"Device suspended\n" ); }/** Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 14 lines · Daniel Vetter
Quoted 4 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catchQuoted 8 lines
more problems if we check the RPM refcount. After that one drops to zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this case.
Quoted 4 lines
Why do we want to avoid asserts firing while we go through the suspend
handler? Callingassert_device_not_suspendedfrom within rpm suspend/resume code sounds like a bug. Where/why does this happen?
Yea, disable_rpm_asserts() is misnamed. Should be disable_rpm_wakelock_asserts(). Will change that in the next iteration.
Quoted 102 lines
-Daniel
Quoted 100 lines
While at it remove the
HAS_RUNTIME_PMcheck, the pm.suspended flag is
false and the RPM refcount is non-zero on all platforms that don't support RPM.This caught additional WARNs from the atomic path, those will be fixed
as a follow-up.v2:
- remove the redundantHAS_RUNTIME_PMcheck (Ville)Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++drivers/gpu/drm/i915/intel_runtime_pm.c| 14 ++++++++++++--3 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -1494,6 +1494,9 @@ static int intel_runtime_suspend(struct device *device)
return-EAGAIN;
}drivers/gpu/drm/i915/i915_drv.c +3
-0+ + dev_priv->pm.disable_suspended_assert = true; +/*
* We are safe here against re-faults, since the fault handler takes
* an RPM reference.drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -1518,6 +1521,8 @@ static int intel_runtime_suspend(struct device *device) intel_uncore_forcewake_reset(dev, false); dev_priv->pm.suspended = true;drivers/gpu/drm/i915/i915_drv.c +2
-0+ dev_priv->pm.disable_suspended_assert = false; +/*
* FIXME: We really should find a document that references the arguments
* used below!drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -1599,6 +1599,11 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +/* +* Used for the duration of runtime suspend to avoid false device
drivers/gpu/drm/i915/i915_drv.h +3
-0+* suspended asserts. +*/ +bool disable_suspended_assert;bool suspended;
boolirqs_enabled;
};drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)
voidassert_device_not_suspended(struct drm_i915_private *dev_priv)
{drivers/gpu/drm/i915/intel_runtime_pm.c +0
-1- WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv-Quoted 1 line
pm.suspended,
drivers/gpu/drm/i915/intel_runtime_pm.c +7
-1- "Device suspended\n"); +int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage = atomic_read(&dev_priv->dev->dev-Quoted 1 line
power.usage_count);
drivers/gpu/drm/i915/intel_runtime_pm.c +5
-0+#else + rpm_usage =1 ; +#endif + + WARN_ONCE(dev_priv->pm.suspended || !rpm_usage, "Devicesuspended\n");
}
/**Signature · 1 line
2.5.0
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 17 lines · Imre Deak
Quoted 16 lines · Daniel Vetter
Quoted 14 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catch
more problems if we check the RPM refcount. After that one drops to
zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this
case.
Quoted 8 lines
Quoted 4 lines
Why do we want to avoid asserts firing while we go through the suspend
handler? Callingassert_device_not_suspendedfrom within rpm suspend/resume code sounds like a bug. Where/why does this happen?Yea, disable_rpm_asserts() is misnamed. Should be
disable_rpm_wakelock_asserts(). Will change that in the next iteration.
Ok, misunderstood your question. assert_device_not_suspended() is called during runtime suspend since we're accessing the HW until the point we set dev_priv->pm.suspended = true. Atm this wouldn't trigger a WARN, since assert_device_not_suspended() only checks pm.suspended and that will check out fine, but once we start to check HW accesses against the actual RPM refcount we want to disable the asserts on those in the handlers, since there the refcount is zero. Hence disabling it explicitly around the handlers, but we would still keep checking pm.suspended.
Hope this explains,
Imre
Quoted 95 lines
Quoted 95 lines
-Daniel
Quoted 92 lines
While at it remove the
HAS_RUNTIME_PMcheck, the pm.suspended flag
is
false and the RPM refcount is non-zero on all platforms that don't
support RPM.This caught additional WARNs from the atomic path, those will be fixed
as a follow-up.v2:
- remove the redundantHAS_RUNTIME_PMcheck (Ville)Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++drivers/gpu/drm/i915/intel_runtime_pm.c| 14 ++++++++++++--3 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -1494,6 +1494,9 @@ static int intel_runtime_suspend(struct device *device)
return-EAGAIN;
}drivers/gpu/drm/i915/i915_drv.c +3
-0+ + dev_priv->pm.disable_suspended_assert = true; +/*
* We are safe here against re-faults, since the fault handler takes
* an RPM reference.drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -1518,6 +1521,8 @@ static int intel_runtime_suspend(struct device *device) intel_uncore_forcewake_reset(dev, false); dev_priv->pm.suspended = true;drivers/gpu/drm/i915/i915_drv.c +2
-0+ dev_priv->pm.disable_suspended_assert = false; +/*
* FIXME: We really should find a document that references
the arguments
* used below!drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -1599,6 +1599,11 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +/* +* Used for the duration of runtime suspend to avoid false
devicedrivers/gpu/drm/i915/i915_drv.h +3
-0+* suspended asserts. +*/ +bool disable_suspended_assert;bool suspended;
boolirqs_enabled;
};drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -2120,8 +2120,18 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)
voidassert_device_not_suspended(struct drm_i915_private *dev_priv)
{drivers/gpu/drm/i915/intel_runtime_pm.c +0
-1- WARN_ONCE(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv-Quoted 1 line
pm.suspended,
drivers/gpu/drm/i915/intel_runtime_pm.c +7
-1- "Device suspended\n"); +int rpm_usage; + +if (dev_priv->pm.disable_suspended_assert) +return ; + +#ifdef CONFIG_PM + rpm_usage = atomic_read(&dev_priv->dev->dev-Quoted 1 line
power.usage_count);
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +5
-0+#else + rpm_usage =1 ; +#endif + + WARN_ONCE(dev_priv->pm.suspended || !rpm_usage, "Devicesuspended\n");
}
/**
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 27 lines · Imre Deak
Quoted 17 lines · Imre Deak
Quoted 16 lines · Daniel Vetter
Quoted 14 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catch
more problems if we check the RPM refcount. After that one drops to
zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this
case.Quoted 8 lines
Quoted 4 lines
Why do we want to avoid asserts firing while we go through the suspend
handler? Callingassert_device_not_suspendedfrom within rpm suspend/resume code sounds like a bug. Where/why does this happen?Yea, disable_rpm_asserts() is misnamed. Should be
disable_rpm_wakelock_asserts(). Will change that in the next iteration.
Quoted 9 lines
Ok, misunderstood your question.
assert_device_not_suspended()is called during runtime suspend since we're accessing the HW until the point we setdev_priv->pm.suspended= true. Atm this wouldn't trigger a WARN, sinceassert_device_not_suspended()only checks pm.suspended and that will check out fine, but once we start to check HW accesses against the actual RPM refcount we want to disable the asserts on those in the handlers, since there the refcount is zero. Hence disabling it explicitly around the handlers, but we would still keep checking pm.suspended.
That seems like we're mixing up 2 asserts:
- assert_device_not_suspended: To be used in runtime_suspend code.
- assert_holding_rpm_wakelock (or whatever, I'm bad at names): check the count.
What am I missing?
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 38 lines · Daniel Vetter
Quoted 27 lines · Imre Deak
Quoted 17 lines · Imre Deak
Quoted 16 lines · Daniel Vetter
Quoted 14 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catch
more problems if we check the RPM refcount. After that one drops to
zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this
case.Quoted 8 lines
Quoted 4 lines
Why do we want to avoid asserts firing while we go through the suspend
handler? Callingassert_device_not_suspendedfrom within rpm suspend/resume code sounds like a bug. Where/why does this happen?Yea, disable_rpm_asserts() is misnamed. Should be
disable_rpm_wakelock_asserts(). Will change that in the next iteration.Quoted 9 lines
Ok, misunderstood your question.
assert_device_not_suspended()is called during runtime suspend since we're accessing the HW until the point we setdev_priv->pm.suspended= true. Atm this wouldn't trigger a WARN, sinceassert_device_not_suspended()only checks pm.suspended and that will check out fine, but once we start to check HW accesses against the actual RPM refcount we want to disable the asserts on those in the handlers, since there the refcount is zero. Hence disabling it explicitly around the handlers, but we would still keep checking pm.suspended.
Quoted 4 lines
That seems like we're mixing up 2 asserts:
-assert_device_not_suspended: To be used inruntime_suspendcode.
-assert_holding_rpm_wakelock(or whatever, I'm bad at names): check the count.
We call this assert (atm assert_device_not_suspended()) from low level register access helpers, so we can't distinguish between calling one or the other assert depending on whether we are on the rpm suspend path or not. What this patch does is to switch all the places where call assert_device_not_suspended() to assert_rpm_wakelock_held(), since that one provides a bigger coverage. Since this change will also affect the low level reg access functions which are called during rpm suspend, we need to disable part of the assert that checks for the refcount which is known to be zero there.
Otherwise assert_rpm_wakelock_held() also includes assert_device_not_suspended(), since that should be true in all other cases.
Quoted 3 lines
What am I missing?
-Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 54 lines · Imre Deak
Quoted 38 lines · Daniel Vetter
Quoted 27 lines · Imre Deak
Quoted 17 lines · Imre Deak
Quoted 16 lines · Daniel Vetter
Quoted 14 lines · Imre Deak
Atm, we assert that the device is not suspended after the point when the
HW is truly put to a suspended state. This is fine, but we can catch
more problems if we check the RPM refcount. After that one drops to
zero
we shouldn't access the HW any more, although the actual suspend may be
delayed. The only complication is that we want to avoid asserts while
the suspend handler itself is running, so add a flag to handle this
case.Quoted 8 lines
Quoted 4 lines
Why do we want to avoid asserts firing while we go through the suspend
handler? Callingassert_device_not_suspendedfrom within rpm suspend/resume code sounds like a bug. Where/why does this happen?Yea, disable_rpm_asserts() is misnamed. Should be
disable_rpm_wakelock_asserts(). Will change that in the next iteration.Quoted 9 lines
Ok, misunderstood your question.
assert_device_not_suspended()is called during runtime suspend since we're accessing the HW until the point we setdev_priv->pm.suspended= true. Atm this wouldn't trigger a WARN, sinceassert_device_not_suspended()only checks pm.suspended and that will check out fine, but once we start to check HW accesses against the actual RPM refcount we want to disable the asserts on those in the handlers, since there the refcount is zero. Hence disabling it explicitly around the handlers, but we would still keep checking pm.suspended.Quoted 4 lines
That seems like we're mixing up 2 asserts:
-assert_device_not_suspended: To be used inruntime_suspendcode.
-assert_holding_rpm_wakelock(or whatever, I'm bad at names): check the count.We call this assert (atm
assert_device_not_suspended()) from low level register access helpers, so we can't distinguish between calling one or the other assert depending on whether we are on the rpm suspend path or not. What this patch does is to switch all the places where callassert_device_not_suspended()to assert_rpm_wakelock_held(), since that one provides a bigger coverage. Since this change will also affect the low level reg access functions which are called during rpm suspend, we need to disable part of the assert that checks for the refcount which is known to be zero there.
Quoted 3 lines
Otherwise
assert_rpm_wakelock_held()also includesassert_device_not_suspended(), since that should be true in all other cases.
Ok, that makes sense. Should be in the commit message ;-)
Instead of cooking our own, what about checking pci_dev->base.power.runtim_status == PM_SUSPENDING plus a comment? -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915: make assert_device_not_suspended more precise
Quoted 9 lines · Daniel Vetter
Quoted 6 lines · Imre Deak
Quoted 1 line · Daniel Vetter
On Wed, Nov 18, 2015 at 04:58:46PM +0200, Imre Deak wrote:
Otherwise
assert_rpm_wakelock_held()also includesassert_device_not_suspended(), since that should be true in all other cases.Ok, that makes sense. Should be in the commit message ;-)
Yea, I pieced together the changes on the way based on the discussion and ideas from Chris, so it's not all in the log:) Will update it.
Quoted 2 lines
Instead of cooking our own, what about checking
pci_dev->base.power.runtim_status==PM_SUSPENDINGplus a comment?
Yea, I was thinking also about that. If you mean to use it instead of the new wakelock ref: the problem with that is that PM_SUSPENDING gets set only right before the handler is called (with an optional delay + work item). But we want to check things already before, right after the last ref is dropped from the driver's POV. This has btw the benefit that we have coverage even if RPM is completely disabled.
If you meant to use RPM_SUSPENDED instead of pm.suspended, perhaps we could do that. The only drawback that I can see now is accessing RPM internals, not sure how big of an issue that is.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: add assert_device_not_suspended to GGTT PTE updaters
In reply to Imre DeakThe device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +8 -0
@@ -2358,6 +2358,8 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ;/* shut up gcc */ +assert_device_not_suspended (vm->dev->dev_private); +for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_dma_address (sg_iter.sg) + (sg_iter.sg_pgoffset <<PAGE_SHIFT );
@@ -2404,6 +2406,8 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ; +assert_device_not_suspended (vm->dev->dev_private); +for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter);iowrite32 (vm->pte_encode (addr, level, true, flags), >t_entries[i]);
@@ -2442,6 +2446,8 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))
@@ -2468,6 +2474,8 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: add assert_device_not_suspended to GGTT PTE updaters
Quoted 13 lines · Imre Deak
The device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c static void gen8_ggtt_insert_entries(struct i915_address_space *vm, · line 2362
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -2358,6 +2358,8 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ;/* shut up gcc */ +assert_device_not_suspended (vm->dev->dev_private); +
We do have the GFX_FLSH_CNTL_GEN6 write in the insert_entries hooks, which should already do the check. But I see no harm in doing it explicitly as well. Serves as documentation if nothing more. The clear_range hooks don't do any register access, so there we should definitely have this.
drivers/gpu/drm/i915/i915_gem_gtt.c static void gen6_ggtt_insert_entries(struct i915_address_space *vm, · line 2409
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_dma_address (sg_iter.sg) + (sg_iter.sg_pgoffset <<PAGE_SHIFT );@@ -2404,6 +2406,8 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ; +assert_device_not_suspended (vm->dev->dev_private);
There's already a dev_priv around in all of these AFAICS.
Quoted 29 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +5
-0+for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter);iowrite32 (vm->pte_encode (addr, level, true, flags), >t_entries[i]);@@ -2442,6 +2446,8 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))@@ -2468,6 +2474,8 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: add assert_device_not_suspended to GGTT PTE updaters
Quoted 20 lines · Ville Syrjälä
Quoted 19 lines · Imre Deak
The device should be on when updating the GGTT PTEs, so add an assert to
all relevant places.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -2358,6 +2358,8 @@ static void gen8_ggtt_insert_entries(structi915_address_space *vm, struct sg_page_iter sg_iter;dma_addr_t addr =0 ;/* shut up gcc */
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c static void gen8_ggtt_insert_entries(struct · line 2363
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0+assert_device_not_suspended (vm->dev->dev_private); +We do have the
GFX_FLSH_CNTL_GEN6write in theinsert_entrieshooks, which should already do the check. But I see no harm in doing it explicitly as well. Serves as documentation if nothing more. Theclear_rangehooks don't do any register access, so there we should definitely have this.
Yes, I think it's better for symmetry with the other updaters. And it's a WARN_ONCE, so shouldn't add noise.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr = sg_dma_address(sg_iter.sg) +drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0(sg_iter.sg_pgoffset <<PAGE_SHIFT );@@ -2404,6 +2406,8 @@ static void gen6_ggtt_insert_entries(structi915_address_space *vm, struct sg_page_iter sg_iter;dma_addr_t addr =0 ;
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_gtt.c static void gen6_ggtt_insert_entries(struct · line 2410
Quoted 1 line
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0+assert_device_not_suspended (vm->dev->dev_private);There's already a
dev_privaround in all of these AFAICS.
Yep, just copy pasted these.. Will fix them.
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0+for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter);iowrite32(vm->pte_encode(addr, level, true,
flags), >t_entries[i]);drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -2442,6 +2446,8 @@ static void gen8_ggtt_clear_range(structi915_address_space *vm, const int max_entries = gtt_total_entries(dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); + if (WARN(num_entries > max_entries,drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))@@ -2468,6 +2474,8 @@ static void gen6_ggtt_clear_range(structi915_address_space *vm, const int max_entries = gtt_total_entries(dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (vm->dev->dev_private); + if (WARN(num_entries > max_entries,drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))Signature · 1 line
2.5.0
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/4 drm/i915: add assert_device_not_suspended to GGTT PTE updaters
In reply to Imre DeakThe device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
v2:
- use the existing dev_priv directly everywhere (Ville)
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +8 -0
@@ -2358,6 +2358,8 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ;/* shut up gcc */ +assert_device_not_suspended (dev_priv); +for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_dma_address (sg_iter.sg) + (sg_iter.sg_pgoffset <<PAGE_SHIFT );
@@ -2404,6 +2406,8 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,struct sg_page_iter sg_iter;dma_addr_t addr =0 ; +assert_device_not_suspended (dev_priv); +for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter);iowrite32 (vm->pte_encode (addr, level, true, flags), >t_entries[i]);
@@ -2442,6 +2446,8 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (dev_priv); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))
@@ -2468,6 +2474,8 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +assert_device_not_suspended (dev_priv); +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/4] drm/i915: add assert_device_not_suspended to GGTT PTE updaters
Quoted 7 lines · Imre Deak
The device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
v2:
- use the existingdev_privdirectly everywhere (Ville)Signed-off-by Imre Deak <[email protected]>
For completeness, add one to i915_ggtt_insert_entries(). Yes, I know that we never will support rpm on any of those devices, but we may as well be consistent in documenting that these functions will write through the magic PCI region.
An issue I see here is dev_priv->pm.suspended doesn't actually say that rpm can't suspend during the GGTT PTEs writes. Would we not want something more like assert_rpm_wakelock() and !dev_priv->pm.can_suspend? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/4] drm/i915: add assert_device_not_suspended to GGTT PTE updaters
Quoted 7 lines · Chris Wilson
Quoted 6 lines · Imre Deak
The device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
v2:
- use the existingdev_privdirectly everywhere (Ville)
Quoted 6 lines
Quoted 1 line
Signed-off-by Imre Deak <[email protected]>For completeness, add one to
i915_ggtt_insert_entries(). Yes, I know that we never will support rpm on any of those devices, but we may as well be consistent in documenting that these functions will write through the magic PCI region.
Ok, forgot about that one.
Quoted 3 lines
An issue I see here is
dev_priv->pm.suspendeddoesn't actually say that rpm can't suspend during the GGTT PTEs writes. Would we not want something more likeassert_rpm_wakelock()and !dev_priv->pm.can_suspend?
Well, after this patchset we assert that the RPM refcount!=0 too, which should guarantee that provided that pm.suspended=false as well. It's possible to have a non-zero refcount with a suspended state (in case of rpm_get_no_resume).
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/4] drm/i915: add assert_device_not_suspended to GGTT PTE updaters
Quoted 17 lines · Imre Deak
Quoted 7 lines · Chris Wilson
Quoted 6 lines · Imre Deak
The device should be on when updating the GGTT PTEs, so add an assert to all relevant places.
v2:
- use the existingdev_privdirectly everywhere (Ville)Quoted 6 lines
Quoted 1 line
Signed-off-by Imre Deak <[email protected]>For completeness, add one to
i915_ggtt_insert_entries(). Yes, I know that we never will support rpm on any of those devices, but we may as well be consistent in documenting that these functions will write through the magic PCI region.Ok, forgot about that one.
Quoted 8 lines
Quoted 3 lines
An issue I see here is
dev_priv->pm.suspendeddoesn't actually say that rpm can't suspend during the GGTT PTEs writes. Would we not want something more likeassert_rpm_wakelock()and !dev_priv->pm.can_suspend?Well, after this patchset we assert that the RPM refcount!=0 too, which should guarantee that provided that pm.suspended=false as well. It's possible to have a non-zero refcount with a suspended state (in case of
rpm_get_no_resume).
But you are right that assert_device_not_suspended doesn't reflect that completely, so I could rename it.
Quoted 4 lines
Quoted 3 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx