drm/i915: improve the RPM device suspended assert
Subsystems (2)
v4 cover drm/i915: improve the RPM device suspended assert
This is v4 of [1]. It has the following changes:
- fix module reload that got broken in v3 due to removal of HAS_RUNTIME_PM (added patch 1-3 + revised patch 4)
- disable the wakeref asserts in the IRQ handlers and RPS work too (revised patch 7)
Imre Deak (10):
drm/i915: clarify comment about mandatory RPM put/get during driver
load/unload
drm/i915: disable power well support on platforms without runtime PM
support
drm/i915: refactor RPM disabling due to RC6 being disabled drm/i915: remove HAS_RUNTIME_PM check from RPM get/put/assert helpers drm/i915: add assert_rpm_wakelock_held helper
drm/i915: use assert_rpm_wakelock_held instead of opencoding it drm/i915: add support for checking if we hold an RPM reference drm/i915: check that we hold an RPM wakelock ref before we put it drm/i915: add support for checking RPM atomic sections drm/i915: check that we are in an RPM atomic section in GGTT PTE
updaters
drivers/gpu/drm/i915/i915_dma.c | 7 ++++ drivers/gpu/drm/i915/i915_drv.c | 39 ++++++++++++++++-- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_gem_gtt.c | 33 +++++++++++++++ drivers/gpu/drm/i915/i915_irq.c | 73 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 72 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 57 ++++++++++++------------- drivers/gpu/drm/i915/intel_uncore.c | 23 ++++------- 9 files changed, 270 insertions(+), 53 deletions(-)
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/10 drm/i915: clarify comment about mandatory RPM put/get during driver load/unload
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +13 -2
@@ -1975,9 +1975,15 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv)*/ void intel_power_domains_fini (struct drm_i915_private *dev_priv) { -/* The i915.ko module is still not prepared to be loaded when +/* +* The i915.ko module is still not prepared to be loaded when * the power well is not enabled, so just enable it in case -* we're going to unload/reload. */ +* we're going to unload/reload. +* The following also reacquires the RPM reference the core passed +* to the driver during loading, which is dropped in +* intel_runtime_pm_enable(). We have to hand back the control of the +* device to the core with this reference held. +*/ intel_display_set_init_power (dev_priv, true);/* Remove the refcount we took to keep power well support disabled. */
@@ -2313,6 +2319,11 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device); +/* +* The core calls the driver load handler with an RPM reference held. +* We drop that here and will reacquire it during unloading in +* intel_power_domains_fini(). +*/ pm_runtime_put_autosuspend (device); }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/10] drm/i915: clarify comment about mandatory RPM put/get during driver load/unload
Hi,
Quoted 1 line · Imre Deak
Signed-off-by Imre Deak <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-1@@ -1975,9 +1975,15 @@ int intel_power_domains_init(structdrm_i915_private *dev_priv) */ void intel_power_domains_fini (struct drm_i915_private *dev_priv) { -/* The i915.ko module is still not prepared to be loaded when
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+/* +* The i915.ko module is still not prepared to be loaded when
drivers/gpu/drm/i915/intel_runtime_pm.c int intel_power_domains_init(struct drm_i915_private *dev_priv) · line 1981
Quoted 3 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +1
-1* the power well is not enabled, so just enable it in case -* we're going to unload/reload. */ +* we're going to unload/reload.
+ * The following also reacquires the RPM reference the core
Quoted 25 lines
passed
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+* to the driver during loading, which is dropped in +* intel_runtime_pm_enable(). We have to hand back the control of the
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+* device to the core with this reference held. +*/ intel_display_set_init_power (dev_priv, true);/* Remove the refcount we took to keep power well support disabled. */
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0@@ -2313,6 +2319,11 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)pm_runtime_mark_last_busy (device );pm_runtime_use_autosuspend (device); +/* +* The core calls the driver load handler with an RPM reference held.
drivers/gpu/drm/i915/intel_runtime_pm.c +1
-0+* We drop that here and will reacquire it during unloading in
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+* intel_power_domains_fini(). +*/ pm_runtime_put_autosuspend (device); }
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/10 drm/i915: disable power well support on platforms without runtime PM support
In reply to Imre DeakAll platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms without runtime PM support. This results in holding the init power domain reference whenever the driver is loaded in addition to an RPM reference, which reflects the reality better and makes it possible to simplify things by removing the HAS_RUNTIME_PM special casing from more places in a follow-up patch.
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_runtime_pm.c +5 -0
@@ -1908,6 +1908,11 @@ static int sanitize_disable_power_well_option(const struct drm_i915_private *dev_priv, int disable_power_well) { +if (!HAS_RUNTIME_PM (dev_priv)) { +DRM_DEBUG_KMS ("No runtime PM support, disabling display power well support\n" ); +return 0 ; + } +if (disable_power_well >=0 )return !!disable_power_well;
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/10] drm/i915: disable power well support on platforms without runtime PM support
Quoted 18 lines · Imre Deak
All platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms without runtime PM support. This results in holding the init power domain reference whenever the driver is loaded in addition to an RPM reference, which reflects the reality better and makes it possible to simplify things by removing the
HAS_RUNTIME_PMspecial casing from more places in a follow-up patch.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0
drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 7 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +4
-0@@ -1908,6 +1908,11 @@ static int sanitize_disable_power_well_option(const struct drm_i915_private *dev_priv, int disable_power_well) { +if (!HAS_RUNTIME_PM (dev_priv)) { +DRM_DEBUG_KMS ("No runtime PM support, disabling display power well support\n" ); +return 0 ; + }
Feels a bit too magic to me. Needs a comment at least, otherwise someone is going to change disable_power_well back into something you can disable at runtime and then all the old stuff might break.
Grabbing an extra rpm reference explicitly for this purpose might be less confusing.
Quoted 6 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +1
-0+if (disable_power_well >=0 )return !!disable_power_well;Signature · 1 line
2.5.0
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/10] drm/i915: disable power well support on platforms without runtime PM support
Quoted 40 lines · Ville Syrjälä
Quoted 30 lines · Imre Deak
All platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms
without runtime PM support. This results in holding the init power domain
reference whenever the driver is loaded in addition to an RPM reference,
which reflects the reality better and makes it possible to simplify things by removing theHAS_RUNTIME_PMspecial casing from more places in
a follow-up patch.Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -1908,6 +1908,11 @@ static intsanitize_disable_power_well_option(const struct
drm_i915_private*dev_priv,
intdisable_power_well) {drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+if (!HAS_RUNTIME_PM (dev_priv)) { + DRM_DEBUG_KMS("No runtime PM support, disablingdisplay power well support\n");
drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+return 0 ; + }Feels a bit too magic to me. Needs a comment at least, otherwise someone
is going to changedisable_power_wellback into something you can disable
at runtime and then all the old stuff might break.
Quoted 2 lines
Grabbing an extra rpm reference explicitly for this purpose might be less confusing.
Ok, agreed. But making power well support depend on RPM still ok with you? I can add then the extra RPM get/put only for !HAS_RUNTIME_PM.
Quoted 8 lines
Quoted 7 lines
+
if (disable_power_well>= 0)
return !!disable_power_well;Signature · 1 line
2.5.0
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/10] drm/i915: disable power well support on platforms without runtime PM support
In reply to Ville SyrjäläQuoted 31 lines · Ville Syrjälä
Quoted 18 lines · Imre Deak
All platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms without runtime PM support. This results in holding the init power domain reference whenever the driver is loaded in addition to an RPM reference, which reflects the reality better and makes it possible to simplify things by removing the
HAS_RUNTIME_PMspecial casing from more places in a follow-up patch.Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 7 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +4
-0@@ -1908,6 +1908,11 @@ static int sanitize_disable_power_well_option(const struct drm_i915_private *dev_priv, int disable_power_well) { +if (!HAS_RUNTIME_PM (dev_priv)) { +DRM_DEBUG_KMS ("No runtime PM support, disabling display power well support\n" ); +return 0 ; + }Feels a bit too magic to me. Needs a comment at least, otherwise someone is going to change
disable_power_wellback into something you can disable at runtime and then all the old stuff might break.
Quoted 2 lines
Grabbing an extra rpm reference explicitly for this purpose might be less confusing.
Changing module options that are marked as debug taints your kernel. Keeping them read-only (so that at least nothing can change at runtime) is imo much preferred, and it's what I started to require on the gem side. Really not worth to have all these checks and complexity around for the off chance some developers want to change the option without reloading the driver.
But yeah comment might be useful here.
-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 02/10] drm/i915: disable power well support on platforms without runtime PM support
Quoted 46 lines · Daniel Vetter
Quoted 41 lines · Ville Syrjälä
Quoted 31 lines · Imre Deak
All platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms
without runtime PM support. This results in holding the init power domain
reference whenever the driver is loaded in addition to an RPM reference,
which reflects the reality better and makes it possible to simplify
things by removing theHAS_RUNTIME_PMspecial casing from more places in
a follow-up patch.Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -1908,6 +1908,11 @@ static intsanitize_disable_power_well_option(const struct
drm_i915_private*dev_priv,
intdisable_power_well) {drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+if (!HAS_RUNTIME_PM (dev_priv)) { + DRM_DEBUG_KMS("No runtime PM support, disablingdisplay power well support\n");
drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+return 0 ; + }Feels a bit too magic to me. Needs a comment at least, otherwise someone
is going to changedisable_power_wellback into something you can disable
at runtime and then all the old stuff might break.Quoted 3 lines
Grabbing an extra rpm reference explicitly for this purpose might be
less confusing.
Quoted 10 lines
Changing module options that are marked as debug taints your kernel. Keeping them read-only (so that at least nothing can change at runtime) is
imo much preferred, and it's what I started to require on the gem side.
Really not worth to have all these checks and complexity around for the
off chance some developers want to change the option without reloading the
driver.
Well, disabling power well support if the platform doesn't support RPM is for simplicity, so we don't need to think about different code paths. What Ville suggested is just for documentation purposes and for ensuring that RPM won't get re-enabled if somebody decides in the future to change how the disable_power_well option behaves. I think it makes sense.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/10] drm/i915: disable power well support on platforms without runtime PM support
Quoted 58 lines · Imre Deak
Quoted 46 lines · Daniel Vetter
Quoted 41 lines · Ville Syrjälä
Quoted 31 lines · Imre Deak
All platforms with power well support have runtime PM support, so simplify things by explicitly disabling power well support on platforms
without runtime PM support. This results in holding the init power domain
reference whenever the driver is loaded in addition to an RPM reference,
which reflects the reality better and makes it possible to simplify
things by removing theHAS_RUNTIME_PMspecial casing from more places in
a follow-up patch.Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -1908,6 +1908,11 @@ static intsanitize_disable_power_well_option(const struct
drm_i915_private*dev_priv,
intdisable_power_well) {drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+if (!HAS_RUNTIME_PM (dev_priv)) { + DRM_DEBUG_KMS("No runtime PM support, disablingdisplay power well support\n");
drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+return 0 ; + }Feels a bit too magic to me. Needs a comment at least, otherwise someone
is going to changedisable_power_wellback into something you can disable
at runtime and then all the old stuff might break.Quoted 3 lines
Grabbing an extra rpm reference explicitly for this purpose might be
less confusing.Quoted 10 lines
Changing module options that are marked as debug taints your kernel. Keeping them read-only (so that at least nothing can change at runtime) is
imo much preferred, and it's what I started to require on the gem side.
Really not worth to have all these checks and complexity around for the
off chance some developers want to change the option without reloading the
driver.
Quoted 6 lines
Well, disabling power well support if the platform doesn't support RPM is for simplicity, so we don't need to think about different code paths. What Ville suggested is just for documentation purposes and for ensuring that RPM won't get re-enabled if somebody decides in the future to change how the
disable_power_welloption behaves. I think it makes sense.
Not sure about this still. I'm thinking that it might reduce coverage if we ever add some power domain refcount asserts to some places.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/10] drm/i915: disable power well support on platforms without runtime PM support
Quoted 78 lines · Ville Syrjälä
Quoted 67 lines · Imre Deak
Quoted 53 lines · Daniel Vetter
Quoted 47 lines · Ville Syrjälä
Quoted 35 lines · Imre Deak
All platforms with power well support have runtime PM support, so
simplify things by explicitly disabling power well support on platforms
without runtime PM support. This results in holding the init power domain
reference whenever the driver is loaded in addition to an RPM reference,
which reflects the reality better and makes it possible to simplify
things by removing theHAS_RUNTIME_PMspecial casing from more
places in
a follow-up patch.Signed-off-by Imre Deak <[email protected]>---
drivers/gpu/drm/i915/intel_runtime_pm.c | 5 +++++1 file changed, 5 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -1908,6 +1908,11 @@ static intsanitize_disable_power_well_option(const struct
drm_i915_private*dev_priv,
intdisable_power_well) {drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+if (!HAS_RUNTIME_PM (dev_priv)) { + DRM_DEBUG_KMS("No runtime PM support,disabling
display power well support\n");drivers/gpu/drm/i915/intel_runtime_pm.c static int · line 1914
Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +2
-0+return 0 ; + }Feels a bit too magic to me. Needs a comment at least, otherwise
someone
is going to changedisable_power_wellback into something you can
disable
at runtime and then all the old stuff might break.Quoted 4 lines
Grabbing an extra rpm reference explicitly for this purpose might
be
less confusing.Quoted 12 lines
Changing module options that are marked as debug taints your kernel.
Keeping them read-only (so that at least nothing can change at runtime) is
imo much preferred, and it's what I started to require on the gem side.
Really not worth to have all these checks and complexity around for
the
off chance some developers want to change the option without reloading the
driver.Quoted 9 lines
Well, disabling power well support if the platform doesn't support RPM
is for simplicity, so we don't need to think about different code paths. What Ville suggested is just for documentation purposes and for
ensuring that RPM won't get re-enabled if somebody decides in the future to change how thedisable_power_welloption behaves. I think it
makes sense.
Quoted 2 lines
Not sure about this still. I'm thinking that it might reduce coverage if we ever add some power domain refcount asserts to some places.
Ok, I'll drop this, it was really just for code path simplification nothing really depends on it.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/10 drm/i915: refactor RPM disabling due to RC6 being disabled
In reply to Imre DeakWe can make the RPM dependency on RC6 explciit in the code by taking an actual RPM reference, instead of avoiding to drop the initial one. This will also enable us to remove the HAS_RUNTIME_PM special casing from more places in the next patch.
--- drivers/gpu/drm/i915/intel_pm.c | 15 +++++++++++++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +15 -0
@@ -6015,7 +6015,17 @@ static void intel_init_emon(struct drm_device *dev)void intel_init_gt_powersave (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private; + i915.enable_rc6 =sanitize_rc6_option (dev, i915.enable_rc6); +/* +* RPM depends on RC6 to save restore the GT HW context, so make RC6 a +* requirement. +*/ +if (!i915.enable_rc6) { +DRM_INFO ("RC6 disabled, disabling runtime PM support\n" ); +intel_runtime_pm_get (dev_priv); + }if (IS_CHERRYVIEW (dev))cherryview_init_gt_powersave (dev);
@@ -6025,10 +6035,15 @@ void intel_init_gt_powersave(struct drm_device *dev)void intel_cleanup_gt_powersave (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private; +if (IS_CHERRYVIEW (dev))return ;else if (IS_VALLEYVIEW (dev))valleyview_cleanup_gt_powersave (dev); + +if (!i915.enable_rc6) +intel_runtime_pm_put (dev_priv); }static void gen6_suspend_rps (struct drm_device *dev)
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -9
@@ -2311,15 +2311,6 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)if (!HAS_RUNTIME_PM (dev))return ; -/* -* RPM depends on RC6 to save restore the GT HW context, so make RC6 a -* requirement. -*/ -if (!intel_enable_rc6 (dev)) { -DRM_INFO ("RC6 disabled, disabling runtime PM support\n" ); -return ; - } -pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/10] drm/i915: refactor RPM disabling due to RC6 being disabled
Quoted 8 lines · Imre Deak
We can make the RPM dependency on RC6 explciit in the code by taking an
actual RPM reference, instead of avoiding to drop the initial one. This
will also enable us to remove theHAS_RUNTIME_PMspecial casing from more places in the next patch.Signed-off-by Imre Deak <[email protected]>
Comment below.
Quoted 12 lines
--- drivers/gpu/drm/i915/intel_pm.c | 15 +++++++++++++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_pm.c +1
-1--- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c
<SNIP>
Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +0
-0@@ -6025,10 +6035,15 @@ void intel_init_gt_powersave(struct drm_device *dev)void intel_cleanup_gt_powersave (struct drm_device *dev)
drivers/gpu/drm/i915/intel_pm.c void intel_init_gt_powersave(struct · line 6047
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5
-0{ +struct drm_i915_private *dev_priv = dev->dev_private; +if (IS_CHERRYVIEW (dev))return ;else if (IS_VALLEYVIEW (dev))valleyview_cleanup_gt_powersave (dev); + +if (!i915.enable_rc6) +intel_runtime_pm_put (dev_priv);
Although intel_enable_rc6 is used in other places, I think this is fine due to the variable being initialized in the counter function.
Regards, Joonas
Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +0
-0}
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH 03/10] drm/i915: refactor RPM disabling due to RC6 being disabled
Quoted 2 lines · Joonas Lahtinen
Quoted 1 line · Imre Deak
We can make the RPM dependency on RC6 explciit in the code by
Typo, s/explciit/explicit/
Quoted 52 lines
Quoted 9 lines
taking
an
actual RPM reference, instead of avoiding to drop the initial one. This
will also enable us to remove theHAS_RUNTIME_PMspecial casing from
more places in the next patch.Signed-off-by Imre Deak <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Comment below.
Quoted 12 lines
--- drivers/gpu/drm/i915/intel_pm.c | 15 +++++++++++++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_pm.c +1
-1--- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c<SNIP>
Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +0
-0@@ -6025,10 +6035,15 @@ void intel_init_gt_powersave(struct drm_device *dev)void intel_cleanup_gt_powersave (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c void intel_init_gt_powersave(struct · line 6047
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5
-0{ +struct drm_i915_private *dev_priv = dev->dev_private; +if (IS_CHERRYVIEW (dev))return ;else if (IS_VALLEYVIEW (dev))valleyview_cleanup_gt_powersave (dev); + +if (!i915.enable_rc6) +intel_runtime_pm_put (dev_priv);Although
intel_enable_rc6is used in other places, I think this is fine
due to the variable being initialized in the counter function.Regards, Joonas
Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +0
-0}
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 4/10 drm/i915: remove HAS_RUNTIME_PM check from RPM get/put/assert helpers
In reply to Imre DeakWe don't really need to check this flag in the get/put/assert helpers, as on platforms without RPM support we won't ever enable RPM. That means pm.suspend will be always false and the assert will be always true.
Do this to simplify the code and to let us extend the RPM asserts to all platforms for a better coverage.
Motivated by Ville.
v2-v3:
- unchanged
v4:
- remove the HAS_RUNTIME_PM check from intel_runtime_pm_enable() too made possible by the previous two patches
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 12 ------------ drivers/gpu/drm/i915/intel_uncore.c | 3 +-- 2 files changed, 1 insertion(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -12
@@ -2237,9 +2237,6 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_get_sync (device);WARN (dev_priv->pm.suspended,"Device still suspended.\n" ); }
@@ -2266,9 +2263,6 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -WARN (dev_priv->pm.suspended,"Getting nosync-ref while suspended.\n" );pm_runtime_get_noresume (device); }
@@ -2286,9 +2280,6 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device); }
@@ -2308,9 +2299,6 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device);
drivers/gpu/drm/i915/intel_uncore.c +1 -2
@@ -53,8 +53,7 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)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" ); +WARN_ONCE (dev_priv->pm.suspended,"Device suspended\n" ); } static inline void
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/10] drm/i915: remove HAS_RUNTIME_PM check from RPM get/put/assert helpers
Quoted 12 lines · Imre Deak
We don't really need to check this flag in the get/put/assert helpers,
as on platforms without RPM support we won't ever enable RPM. That means
pm.suspend will be always false and the assert will be always true.Do this to simplify the code and to let us extend the RPM asserts to all
platforms for a better coverage.Motivated by Ville.
Quoted 8 lines
v2-v3:
- unchanged
v4:
- remove theHAS_RUNTIME_PMcheck fromintel_runtime_pm_enable()too made possible by the previous two patchesSigned-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]> (v3)
Quoted 72 lines
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 12 ------------ drivers/gpu/drm/i915/intel_uncore.c | 3 +-- 2 files changed, 1 insertion(+), 14 deletions(-)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3@@ -2237,9 +2237,6 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_get_sync (device);WARN (dev_priv->pm.suspended,"Device still suspended.\n" );}
drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3@@ -2266,9 +2263,6 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; - WARN(dev_priv->pm.suspended, "Getting nosync-ref while suspended.\n");drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3pm_runtime_get_noresume (device); }@@ -2286,9 +2280,6 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device);}
drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3@@ -2308,9 +2299,6 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0pm_runtime_use_autosuspend (device);drivers/gpu/drm/i915/intel_uncore.c +1
-3@@ -53,8 +53,7 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)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" ); +WARN_ONCE (dev_priv->pm.suspended,"Device suspended\n" ); } static inline void
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: get a permanent RPM reference on platforms w/o RPM support
In reply to Imre DeakCurrently we get a permanent RPM reference if the platform doesn't support RPM, but this is implicit via the dependency of the power well functionality on RPM the RPM support, see sanitize_disable_power_well_option(). Make things more explicit by taking an RPM reference only for the purpose of keeping RPM disabled. This provides better documentation and safety against future changes that would break the above dependency.
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/intel_runtime_pm.c +10 -0
@@ -1992,6 +1992,13 @@ void intel_power_domains_fini(struct drm_i915_private *dev_priv)/* Remove the refcount we took to keep power well support disabled. */ if (!i915.disable_power_well)intel_display_power_put (dev_priv,POWER_DOMAIN_INIT ); + +/* +* Remove the refcount we took in intel_runtime_pm_enable() in case +* the platform doesn't support runtime PM. +*/ +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_get (dev_priv); }static void intel_power_domains_sync_hw (struct drm_i915_private *dev_priv)
@@ -2305,6 +2312,9 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_get (dev_priv); +pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 drm/i915: get a permanent RPM reference on platforms w/o RPM support
Currently we get a permanent RPM reference if the platform doesn't support RPM, but this is implicit via the dependency of the power well functionality on RPM the RPM support, see sanitize_disable_power_well_option(). Make things more explicit by taking an RPM reference only for the purpose of keeping RPM disabled. This provides better documentation and safety against future changes that would break the above dependency.
v2:
- fix intel_runtime_pm_get vs. intel_runtime_pm_put in intel_power_domains_fini()
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/intel_runtime_pm.c +10 -0
@@ -1992,6 +1992,13 @@ void intel_power_domains_fini(struct drm_i915_private *dev_priv)/* Remove the refcount we took to keep power well support disabled. */ if (!i915.disable_power_well)intel_display_power_put (dev_priv,POWER_DOMAIN_INIT ); + +/* +* Remove the refcount we took in intel_runtime_pm_enable() in case +* the platform doesn't support runtime PM. +*/ +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_put (dev_priv); }static void intel_power_domains_sync_hw (struct drm_i915_private *dev_priv)
@@ -2305,6 +2312,9 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_get (dev_priv); +pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4.1/10] drm/i915: get a permanent RPM reference on platforms w/o RPM support
Quoted 8 lines · Imre Deak
Currently we get a permanent RPM reference if the platform doesn't support RPM, but this is implicit via the dependency of the power well functionality on RPM the RPM support, see
sanitize_disable_power_well_option(). Make things more explicit by taking an RPM reference only for the purpose of keeping RPM disabled. This provides better documentation and safety against future changes that would break the above dependency.
Quoted 6 lines
v2:
- fixintel_runtime_pm_getvs.intel_runtime_pm_putinintel_power_domains_fini()Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Imre Deak <[email protected]>
Quoted 34 lines
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +10
-0@@ -1992,6 +1992,13 @@ void intel_power_domains_fini(struct drm_i915_private *dev_priv)/* Remove the refcount we took to keep power well support disabled. */ if (!i915.disable_power_well)intel_display_power_put (dev_priv,POWER_DOMAIN_INIT ); + +/* +* Remove the refcount we took in intel_runtime_pm_enable() in case +* the platform doesn't support runtime PM. +*/ +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_put (dev_priv); }static void intel_power_domains_sync_hw (struct drm_i915_private *dev_priv)@@ -2305,6 +2312,9 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_get (dev_priv); +pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);pm_runtime_use_autosuspend (device);Signature · 1 line
2.5.0
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4.1/10] drm/i915: get a permanent RPM reference on platforms w/o RPM support
Quoted 37 lines · Ville Syrjälä
Quoted 11 lines · Imre Deak
Currently we get a permanent RPM reference if the platform doesn't support RPM, but this is implicit via the dependency of the power well
functionality on RPM the RPM support, seesanitize_disable_power_well_option(). Make things more explicit by taking an RPM reference only for the purpose of keeping RPM disabled.
This provides better documentation and safety against future changes
that would break the above dependency.Quoted 6 lines
v2:
- fixintel_runtime_pm_getvs.intel_runtime_pm_putinintel_power_domains_fini()Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Imre Deak <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>Quoted 16 lines
---
drivers/gpu/drm/i915/intel_runtime_pm.c | 10 ++++++++++1 file changed, 10 insertions(+)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -1992,6 +1992,13 @@ void intel_power_domains_fini(struct drm_i915_private *dev_priv) /* Remove the refcount we took to keep power well supportdisabled. */
if (!i915.disable_power_well)
intel_display_power_put(dev_priv,POWER_DOMAIN_INIT);
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c void intel_power_domains_fini(struct drm_i915_private *dev_priv) · line 2001
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0+ +/* +* Remove the refcount we took in
intel_runtime_pm_enable()in casedrivers/gpu/drm/i915/intel_runtime_pm.c +4
-0+* the platform doesn't support runtime PM. +*/ +if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_put (dev_priv);
Ville noticed another issue here, with this we wouldn't have RPM ref tracking coverage on old platforms. We can solve this by using the low level pm_runtime_put()/pm_runtime_get_sync() for this instead, will send a v3 with this changed.
Quoted 9 lines
Quoted 9 lines
}
static voidintel_power_domains_sync_hw(struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -2305,6 +2312,9 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv) struct drm_device *dev = dev_priv->dev; struct device *device = &dev->pdev->dev;
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +3
-0+if (!HAS_RUNTIME_PM (dev_priv)) +intel_runtime_pm_get (dev_priv); +
pm_runtime_set_autosuspend_delay(device, 10000); /* 10s */pm_runtime_mark_last_busy(device);pm_runtime_use_autosuspend(device);Signature · 1 line
2.5.0
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: get a permanent RPM reference on platforms w/o RPM support
In reply to Imre DeakCurrently we disable RPM functionality on platforms that doesn't support this by not putting/getting the RPM reference we receive from the RPM core during driver loading/unloading respectively. This is somewhat obscure, so make it more explicit by keeping a reference dedicated for this particular purpose whenever the driver is loaded. This makes it possible to remove the HAS_RUNTIME_PM() special casing from every other places in the next patch.
v2:
- fix intel_runtime_pm_get vs. intel_runtime_pm_put in intel_power_domains_fini()
v3:
- take only a low level RPM reference so the ref tracking asserts continue to work (Ville)
- update the commit message
- move the patch earlier for bisectability
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +16 -1
@@ -1975,6 +1975,8 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv)*/ void intel_power_domains_fini (struct drm_i915_private *dev_priv) { +struct device *device = &dev_priv->dev->pdev->dev; +/* * The i915.ko module is still not prepared to be loaded when * the power well is not enabled, so just enable it in case
@@ -1989,6 +1991,13 @@ void intel_power_domains_fini(struct drm_i915_private *dev_priv)/* Remove the refcount we took to keep power well support disabled. */ if (!i915.disable_power_well)intel_display_power_put (dev_priv,POWER_DOMAIN_INIT ); + +/* +* Remove the refcount we took in intel_runtime_pm_enable() in case +* the platform doesn't support runtime PM. +*/ +if (!HAS_RUNTIME_PM (dev_priv)) +pm_runtime_put (device); }static void intel_power_domains_sync_hw (struct drm_i915_private *dev_priv)
@@ -2303,8 +2312,14 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +/* +* Take a permanent reference to disable the RPM functionality and drop +* it only when unloading the driver. Use the low level get/put helpers, +* so the driver's own RPM reference tracking asserts also work on +* platforms without RPM support. +*/ if (!HAS_RUNTIME_PM (dev)) -return ; +pm_runtime_get_sync (device);pm_runtime_set_autosuspend_delay (device,10000 );/* 10s */ pm_runtime_mark_last_busy (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v5 4/10 drm/i915: remove HAS_RUNTIME_PM check from RPM get/put/assert helpers
In reply to Imre DeakWe don't really need to check this flag in the get/put/assert helpers, as on platforms without RPM support we won't ever enable RPM. That means pm.suspend will be always false and the assert will be always true.
Do this to simplify the code and to let us extend the RPM asserts to all platforms for a better coverage.
Motivated by Ville.
v2-v3:
- unchanged
v4:
- remove the HAS_RUNTIME_PM check from intel_runtime_pm_enable() too made possible by the previous two patches
v5:
- rebased on the previous new patch in the series that keeps HAS_RUNTIME_PM() in intel_runtime_pm_enable() with a permanent reference taken there
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 9 --------- drivers/gpu/drm/i915/intel_uncore.c | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -9
@@ -2241,9 +2241,6 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_get_sync (device);WARN (dev_priv->pm.suspended,"Device still suspended.\n" ); }
@@ -2270,9 +2267,6 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -WARN (dev_priv->pm.suspended,"Getting nosync-ref while suspended.\n" );pm_runtime_get_noresume (device); }
@@ -2290,9 +2284,6 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device); }
drivers/gpu/drm/i915/intel_uncore.c +1 -2
@@ -53,8 +53,7 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)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" ); +WARN_ONCE (dev_priv->pm.suspended,"Device suspended\n" ); } static inline void
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v5 04/10] drm/i915: remove HAS_RUNTIME_PM check from RPM get/put/assert helpers
Quoted 22 lines · Imre Deak
We don't really need to check this flag in the get/put/assert helpers,
as on platforms without RPM support we won't ever enable RPM. That means
pm.suspend will be always false and the assert will be always true.Do this to simplify the code and to let us extend the RPM asserts to all
platforms for a better coverage.Motivated by Ville.
v2-v3:
- unchanged
v4:
- remove theHAS_RUNTIME_PMcheck fromintel_runtime_pm_enable()too made possible by the previous two patches
v5:
- rebased on the previous new patch in the series that keepsHAS_RUNTIME_PM()inintel_runtime_pm_enable()with a permanent reference taken there
Quoted 3 lines
Signed-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]> (v3)Reviewed-by Joonas Lahtinen <[email protected]> (v4)
Quoted 61 lines
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 9 --------- drivers/gpu/drm/i915/intel_uncore.c | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-)drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3@@ -2241,9 +2241,6 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_get_sync (device);WARN (dev_priv->pm.suspended,"Device still suspended.\n" );}
drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3@@ -2270,9 +2267,6 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; - WARN(dev_priv->pm.suspended, "Getting nosync-ref while suspended.\n");drivers/gpu/drm/i915/intel_runtime_pm.c +0
-3pm_runtime_get_noresume (device); }@@ -2290,9 +2284,6 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -if (!HAS_RUNTIME_PM (dev)) -return ; -pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device);}
drivers/gpu/drm/i915/intel_uncore.c +1
-3@@ -53,8 +53,7 @@ intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)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" ); +WARN_ONCE (dev_priv->pm.suspended,"Device suspended\n" ); } static inline void
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 5/10 drm/i915: add assert_rpm_wakelock_held helper
In reply to Imre DeakAs a preparation for follow-up patches add a new helper that checks whether we hold an RPM reference, since this is what we want most of the cases. Atm this helper will only check for the HW suspended state, a follow-up patch will do the actual change to check the refcount instead. One exception is the forcewake release timer function, where it's guaranteed that the HW is on even though the RPM refcount drops to zero. This guarantee is provided by flushing the timer in the runtime suspend handler. So leave the assert_device_not_suspended check in place there.
Also rename assert_device_suspended for consistency and export these helpers as a preparation for the follow-up patches.
No functional change.
v3:
- change the assert warning message to be more meaningful (Chris)
--- drivers/gpu/drm/i915/intel_drv.h | 14 ++++++++++++++ drivers/gpu/drm/i915/intel_uncore.c | 20 +++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +14 -0
@@ -1430,6 +1430,20 @@ 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); + +static inline void +assert_rpm_device_not_suspended (struct drm_i915_private *dev_priv) +{ +WARN_ONCE (dev_priv->pm.suspended, +"Device suspended during HW access\n" ); +} + +static inline void +assert_rpm_wakelock_held (struct drm_i915_private *dev_priv) +{ +assert_rpm_device_not_suspended (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_uncore.c +7 -13
@@ -50,12 +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 (dev_priv->pm.suspended,"Device suspended\n" ); -} -static inline void fw_domain_reset (const struct intel_uncore_forcewake_domain *d) {
@@ -235,7 +229,7 @@ static void intel_uncore_fw_release_timer(unsigned long arg)struct intel_uncore_forcewake_domain *domain = (void *)arg;unsigned long irqflags; -assert_device_not_suspended (domain->i915); +assert_rpm_device_not_suspended (domain->i915);spin_lock_irqsave (&domain->i915->uncore.lock, irqflags);if (WARN_ON (domain->wake_count ==0 ))
@@ -627,7 +621,7 @@ hsw_unclaimed_reg_detect(struct drm_i915_private *dev_priv)#define GEN2_READ_HEADER (x) \ u##x val = 0; \ - assert_device_not_suspended(dev_priv); + assert_rpm_wakelock_held(dev_priv);#define GEN2_READ_FOOTER \ trace_i915_reg_rw(false, reg, val, sizeof(val), trace); \
@@ -669,7 +663,7 @@ __gen2_read(64)u32 offset =i915_mmio_reg_offset (reg); \unsigned long irqflags; \ u##x val = 0; \ - assert_device_not_suspended(dev_priv); \ + assert_rpm_wakelock_held(dev_priv); \ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags)#define GEN6_READ_FOOTER \
@@ -802,7 +796,7 @@ __gen6_read(64)#define VGPU_READ_HEADER (x) \ unsigned long irqflags; \ u##x val = 0; \ - assert_device_not_suspended(dev_priv); \ + assert_rpm_device_not_suspended(dev_priv); \ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags)#define VGPU_READ_FOOTER \
@@ -829,7 +823,7 @@ __vgpu_read(64)#define GEN2_WRITE_HEADER \ trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \ - assert_device_not_suspended(dev_priv); \ + assert_rpm_wakelock_held(dev_priv); \#define GEN2_WRITE_FOOTER
@@ -869,7 +863,7 @@ __gen2_write(64)u32 offset =i915_mmio_reg_offset (reg); \unsigned long irqflags; \trace_i915_reg_rw (true, reg, val,sizeof (val), trace); \ -assert_device_not_suspended (dev_priv); \ +assert_rpm_wakelock_held (dev_priv); \ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags)#define GEN6_WRITE_FOOTER \
@@ -1045,7 +1039,7 @@ __gen6_write(64)#define VGPU_WRITE_HEADER \ unsigned long irqflags; \ trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \ - assert_device_not_suspended(dev_priv); \ + assert_rpm_device_not_suspended(dev_priv); \ spin_lock_irqsave(&dev_priv->uncore.lock, irqflags)#define VGPU_WRITE_FOOTER \
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/10] drm/i915: add assert_rpm_wakelock_held helper
Quoted 29 lines · Imre Deak
As a preparation for follow-up patches add a new helper that checks whether we hold an RPM reference, since this is what we want most of the cases. Atm this helper will only check for the HW suspended state, a follow-up patch will do the actual change to check the refcount instead. One exception is the forcewake release timer function, where it's guaranteed that the HW is on even though the RPM refcount drops to zero. This guarantee is provided by flushing the timer in the runtime suspend handler. So leave the
assert_device_not_suspendedcheck in place there.Also rename
assert_device_suspendedfor consistency and export these helpers as a preparation for the follow-up patches.No functional change.
v3:
- change the assert warning message to be more meaningful (Chris)Signed-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 14 ++++++++++++++ drivers/gpu/drm/i915/intel_uncore.c | 20 +++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-)drivers/gpu/drm/i915/intel_drv.h +0
-0
drivers/gpu/drm/i915/intel_drv.h void intel_display_power_get(struct drm_i915_private *dev_priv, · line 1439
Quoted 10 lines
drivers/gpu/drm/i915/intel_drv.h +7
-0@@ -1430,6 +1430,20 @@ 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); + +static inline void +assert_rpm_device_not_suspended (struct drm_i915_private *dev_priv) +{ +WARN_ONCE (dev_priv->pm.suspended, +"Device suspended during HW access\n" ); +}
On irc, Joonas expressed a wish to see all errors during an igt run, i.e. something like
static inline void assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
{
WARN(dev_priv->pm.suspended &&
atomic_inc_return(&dev_priv->pm.errors) < 0,
"Device suspended during HW access\n");
}with
static inti915_pm_errors_get(void *data, u64 *val)
{
struct drm_device *dev = data;
*val = atomic_read(&to_i915(dev)->pm.erors);
return 0;
}static inti915_pm_errors_set(void *data, u64 val)
{
struct drm_device *dev = data;
atomic_set(&to_i915(dev)->pm.errors, val);
return 0;
}DEFINE_SIMPLE_ATTRIBUTE(i915_pm_errors_fops,
i915_pm_errors_get, i915_pm_errors_set, "0x%llx\n");
Then users only see the first WARN (and not swamped when it does go wrong) and igt can echo INT_MIN > /sys/kernel/debug/dri/0/i915_pm_errors to generate a WARN for each failure (and can even do a quick check for any errors during a test by reading back i915_pm_errors). -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 05/10] drm/i915: add assert_rpm_wakelock_held helper
Quoted 89 lines · Chris Wilson
Quoted 43 lines · Imre Deak
As a preparation for follow-up patches add a new helper that checks whether we hold an RPM reference, since this is what we want most of
the cases. Atm this helper will only check for the HW suspended state, a
follow-up patch will do the actual change to check the refcount instead.
One exception is the forcewake release timer function, where it's guaranteed that the HW is on even though the RPM refcount drops to zero.
This guarantee is provided by flushing the timer in the runtime suspend
handler. So leave theassert_device_not_suspendedcheck in place there.Also rename
assert_device_suspendedfor consistency and export these
helpers as a preparation for the follow-up patches.No functional change.
v3:
- change the assert warning message to be more meaningful (Chris)Signed-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]>---
drivers/gpu/drm/i915/intel_drv.h | 14 ++++++++++++++drivers/gpu/drm/i915/intel_uncore.c| 20 +++++++-------------2 files changed, 21 insertions(+), 13 deletions(-)drivers/gpu/drm/i915/intel_drv.h +0
-0@@ -1430,6 +1430,20 @@ void intel_display_power_get(struct drm_i915_private *dev_priv,enum
intel_display_power_domaindomain);
voidintel_display_power_put(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain);drivers/gpu/drm/i915/intel_drv.h void intel_display_power_get(struct drm_i915_private *dev_priv, · line 1439
Quoted 7 lines
drivers/gpu/drm/i915/intel_drv.h +7
-0+ +static inline void +assert_rpm_device_not_suspended (struct drm_i915_private *dev_priv) +{ +WARN_ONCE (dev_priv->pm.suspended, + "Device suspended during HW access\n"); +}On irc, Joonas expressed a wish to see all errors during an igt run, i.e. something like
static inline void
assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv){ WARN(dev_priv->pm.suspended && atomic_inc_return(&dev_priv->pm.errors) < 0, "Device suspended during HW access\n"); }with
static int
i915_pm_errors_get(void *data, u64 *val){ struct drm_device *dev = data; *val = atomic_read(&to_i915(dev)->pm.erors); return 0; }static int
i915_pm_errors_set(void *data, u64 val){ struct drm_device *dev = data; atomic_set(&to_i915(dev)->pm.errors, val); return 0; }DEFINE_SIMPLE_ATTRIBUTE(i915_pm_errors_fops,
i915_pm_errors_get,i915_pm_errors_set, "0x%llx\n");
Quoted 6 lines
Then users only see the first WARN (and not swamped when it does go wrong) and igt can echo
INT_MIN>/sys/kernel/debug/dri/0/i915_pm_errors
to generate a WARN for each failure (and can even do a quick check for
any errors during a test by reading backi915_pm_errors).
Sounds good, we could use this also for other PM related error reporting.
Are you ok to do this as a follow-up?
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/10] drm/i915: add assert_rpm_wakelock_held helper
Quoted 19 lines · Imre Deak
Quoted 18 lines · Chris Wilson
drivers/gpu/drm/i915/intel_drv.h void intel_display_power_get(struct drm_i915_private *dev_priv, · line 1439
Quoted 6 lines · Imre Deak
drivers/gpu/drm/i915/intel_drv.h +6
-0+static inline void +assert_rpm_device_not_suspended (struct drm_i915_private *dev_priv) +{ +WARN_ONCE (dev_priv->pm.suspended, + "Device suspended during HW access\n"); +}On irc, Joonas expressed a wish to see all errors during an igt run, i.e. something like
static inline void
assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv){ WARN(dev_priv->pm.suspended && atomic_inc_return(&dev_priv->pm.errors) < 0, "Device suspended during HW access\n"); }
[snip]
Quoted 4 lines
Sounds good, we could use this also for other PM related error reporting.
Are you ok to do this as a follow-up?
Definitely. We haven't changed any behaviour so far, so this is a new feature.
-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
Joonas Lahtinen
maintainerRe: [PATCH 05/10] drm/i915: add assert_rpm_wakelock_held helper
Quoted 25 lines · Chris Wilson
Quoted 22 lines · Imre Deak
Quoted 21 lines · Chris Wilson
drivers/gpu/drm/i915/intel_drv.h void intel_display_power_get(struct drm_i915_private *dev_priv, · line 1439
Quoted 7 lines · Imre Deak
(quoted diff) +2
-0+static inline void +assert_rpm_device_not_suspended(struct drm_i915_private
*dev_priv)drivers/gpu/drm/i915/intel_drv.h +4
-0+{ +WARN_ONCE (dev_priv->pm.suspended, +"Device suspended during HW access\n" ); +}On irc, Joonas expressed a wish to see all errors during an igt run,
i.e. something likestatic inline void
assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv){ WARN(dev_priv->pm.suspended && atomic_inc_return(&dev_priv->pm.errors) < 0, "Device suspended during HW access\n"); }[snip]
Quoted 7 lines
Quoted 4 lines
Sounds good, we could use this also for other PM related error reporting.
Are you ok to do this as a follow-up?
Definitely. We haven't changed any behaviour so far, so this is a new feature.
I'd prefer to currently add it as WARN instead of WARN_ONCE, and then reduce the message amount with follow-up. This way we'll get more useful CI results immediately.
Regards, Joonas
Quoted 2 lines
-Chris
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/10] drm/i915: add assert_rpm_wakelock_held helper
Quoted 31 lines · Joonas Lahtinen
Quoted 30 lines · Chris Wilson
Quoted 22 lines · Imre Deak
Quoted 21 lines · Chris Wilson
drivers/gpu/drm/i915/intel_drv.h void intel_display_power_get(struct drm_i915_private *dev_priv, · line 1439
Quoted 7 lines · Imre Deak
(quoted diff) +2
-0+static inline void +assert_rpm_device_not_suspended(struct drm_i915_private
*dev_priv)drivers/gpu/drm/i915/intel_drv.h +4
-0+{ +WARN_ONCE (dev_priv->pm.suspended, + "Device suspended during HW access\n"); +}On irc, Joonas expressed a wish to see all errors during an igt run,
i.e. something likestatic inline void
assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv){ WARN(dev_priv->pm.suspended && atomic_inc_return(&dev_priv->pm.errors) < 0, "Device suspended during HW access\n"); }[snip]
Quoted 4 lines
Sounds good, we could use this also for other PM related error reporting.
Are you ok to do this as a follow-up?
Quoted 7 lines
Quoted 3 lines
Definitely. We haven't changed any behaviour so far, so this is a new
feature.I'd prefer to currently add it as WARN instead of
WARN_ONCE, and then reduce the message amount with follow-up. This way we'll get more useful CI results immediately.
And more annoyed upstream users.. Really adding that knob is a good idea and it doesn't take long to implement it, but we could make progress if we did it as a follow-up.
Quoted 5 lines
Regards, Joonas
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 6/10 drm/i915: use assert_rpm_wakelock_held 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
@@ -538,8 +538,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_rpm_wakelock_held (dev_priv);assert_csr_loaded (dev_priv); }
@@ -553,8 +552,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_rpm_wakelock_held (dev_priv); }static void gen9_enable_dc5 (struct drm_i915_private *dev_priv)
@@ -2238,7 +2236,7 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;pm_runtime_get_sync (device); -WARN (dev_priv->pm.suspended,"Device still suspended.\n" ); +assert_rpm_wakelock_held (dev_priv); }/**
@@ -2263,7 +2261,7 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; -WARN (dev_priv->pm.suspended,"Getting nosync-ref while suspended.\n" ); +assert_rpm_wakelock_held (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_rpm_wakelock_held (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
PATCH v4 7/10 drm/i915: add support for checking if we hold an RPM reference
In reply to Imre DeakAtm, we assert that the device is not suspended until the point when the device is truly put to a suspended state. This is fine, but we can catch more problems if we check that RPM refcount is non-zero. After that one drops to zero we shouldn't access the device any more, even if the actual device suspend may be delayed. Change assert_rpm_wakelock_held() accordingly to check for a non-zero RPM refcount in addition to the current device-not-suspended check.
For the new asserts to work we need to annotate every place explicitly in the code where we expect that the device is powered. The places where we only assume this, but may not hold an RPM reference:
- driver load
We assume the device to be powered until we enable RPM. Make this explicit by taking an RPM reference around the load function.
- system and runtime sudpend/resume handlers
These handlers are called when the RPM reference becomes 0 and know the exact point after which the device can get powered off. Disable the RPM-reference-held check for their duration.
- the IRQ, hangcheck and RPS work handlers
These handlers are flushed in the system/runtime suspend handler before the device is powered off, so it's guaranteed that they won't run while the device is powered off even though they don't hold any RPM reference. Disable the RPM-reference-held check for their duration.
In all these cases we still check that the device is not suspended. These explicit annotations also have the positive side effect of documenting our assumptions better.
This caught additional WARNs from the atomic modeset path, those should be fixed separately.
v2:
- remove the redundant HAS_RUNTIME_PM check (moved to patch 1) (Ville) v3:
- use a new dedicated RPM wakelock refcount to also catch cases where our own RPM get/put functions were not called (Chris)
- assert also that the new RPM wakelock refcount is 0 in the RPM suspend handler (Chris)
- change the assert error message to be more meaningful (Chris)
- prevent false assert errors and check that the RPM wakelock is 0 in the RPM resume handler too
- prevent false assert errors in the hangcheck work too
- add a device not suspended assert check to the hangcheck work v4:
- rename disable/enable_rpm_asserts to disable/enable_rpm_wakeref_asserts and wakelock_count to wakeref_count
- disable the wakeref asserts in the IRQ handlers and RPS work too
- update/clarify commit message
--- drivers/gpu/drm/i915/i915_dma.c | 7 ++++ drivers/gpu/drm/i915/i915_drv.c | 39 ++++++++++++++++-- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_irq.c | 73 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 41 ++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 + drivers/gpu/drm/i915/intel_runtime_pm.c | 6 +++ 7 files changed, 158 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +7 -0
@@ -896,6 +896,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)intel_pm_setup (dev); +intel_runtime_pm_get (dev_priv); +intel_display_crc_init (dev);i915_dump_device_info (dev_priv);
@@ -1085,6 +1087,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)i915_audio_component_init (dev_priv); +intel_runtime_pm_put (dev_priv); +return 0 ; out_power_well:
@@ -1120,6 +1124,9 @@ free_priv:kmem_cache_destroy (dev_priv->requests);kmem_cache_destroy (dev_priv->vmas);kmem_cache_destroy (dev_priv->objects); + +intel_runtime_pm_put (dev_priv); +kfree (dev_priv);return ret; }
drivers/gpu/drm/i915/i915_drv.c +35 -4
@@ -580,6 +580,8 @@ static int i915_drm_suspend(struct drm_device *dev) dev_priv->modeset_restore =MODESET_SUSPENDED ;mutex_unlock (&dev_priv->modeset_restore_lock); +disable_rpm_wakeref_asserts (dev_priv); +/* We do a lot of poking in a lot of registers, make sure they work * properly. */ intel_display_set_init_power (dev_priv, true);
@@ -592,7 +594,7 @@ static int i915_drm_suspend(struct drm_device *dev)if (error) {dev_err (&dev->pdev->dev,"GEM idle failed, resume might fail\n" ); -return error; + goto out; }intel_guc_suspend (dev);
@@ -635,7 +637,10 @@ static int i915_drm_suspend(struct drm_device *dev)if (HAS_CSR (dev_priv))flush_work (&dev_priv->csr.work); -return 0 ; +out: +enable_rpm_wakeref_asserts (dev_priv); + +return error; }static int i915_drm_suspend_late (struct drm_device *drm_dev,bool hibernation)
@@ -644,6 +649,8 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation)bool fw_csr;int ret; +disable_rpm_wakeref_asserts (dev_priv); + fw_csr =suspend_to_idle (dev_priv) && dev_priv->csr.dmc_payload;/* * In case of firmware assisted context save/restore don't manually
@@ -662,7 +669,7 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation)if (!fw_csr)intel_power_domains_init_hw (dev_priv, true); -return ret; + goto out; }pci_disable_device (drm_dev->pdev);
@@ -683,7 +690,10 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation) dev_priv->suspended_to_idle =suspend_to_idle (dev_priv); -return 0 ; +out: +enable_rpm_wakeref_asserts (dev_priv); + +return ret; }int i915_suspend_switcheroo (struct drm_device *dev,pm_message_t state)
@@ -714,6 +724,8 @@ static int i915_drm_resume(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +disable_rpm_wakeref_asserts (dev_priv); +mutex_lock (&dev->struct_mutex);i915_gem_restore_gtt_mappings (dev);mutex_unlock (&dev->struct_mutex);
@@ -778,6 +790,8 @@ static int i915_drm_resume(struct drm_device *dev)drm_kms_helper_poll_enable (dev); +enable_rpm_wakeref_asserts (dev_priv); +return 0 ; }
@@ -802,6 +816,8 @@ static int i915_drm_resume_early(struct drm_device *dev)pci_set_master (dev->pdev); +disable_rpm_wakeref_asserts (dev_priv); +if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv)) ret =vlv_resume_prepare (dev_priv, false);if (ret)
@@ -823,6 +839,8 @@ static int i915_drm_resume_early(struct drm_device *dev) out: dev_priv->suspended_to_idle = false; +enable_rpm_wakeref_asserts (dev_priv); +return ret; }
@@ -1455,6 +1473,9 @@ static int intel_runtime_suspend(struct device *device)return -EAGAIN ; } + +disable_rpm_wakeref_asserts (dev_priv); +/* * We are safe here against re-faults, since the fault handler takes * an RPM reference.
@@ -1474,10 +1495,15 @@ static int intel_runtime_suspend(struct device *device)DRM_ERROR ("Runtime suspend failed, disabling it (%d)\n" , ret);intel_runtime_pm_enable_interrupts (dev_priv); +enable_rpm_wakeref_asserts (dev_priv); +return ret; }intel_uncore_forcewake_reset (dev, false); + +enable_rpm_wakeref_asserts (dev_priv); +WARN_ON_ONCE (atomic_read (&dev_priv->pm.wakeref_count)); dev_priv->pm.suspended = true;/*
@@ -1521,6 +1547,9 @@ static int intel_runtime_resume(struct device *device)DRM_DEBUG_KMS ("Resuming device\n" ); +WARN_ON_ONCE (atomic_read (&dev_priv->pm.wakeref_count)); +disable_rpm_wakeref_asserts (dev_priv); +intel_opregion_notify_adapter (dev,PCI_D0 ); dev_priv->pm.suspended = false;
@@ -1555,6 +1584,8 @@ static int intel_runtime_resume(struct device *device)intel_enable_gt_powersave (dev); +enable_rpm_wakeref_asserts (dev_priv); +if (ret)DRM_ERROR ("Runtime resume failed, disabling it (%d)\n" , ret);else
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1602,6 +1602,7 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +atomic_t wakeref_count;bool suspended;bool irqs_enabled; };
drivers/gpu/drm/i915/i915_irq.c +67 -6
205 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +41 -0
47 lines not on this page · raw message
drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -7247,4 +7247,5 @@ void intel_pm_setup(struct drm_device *dev)INIT_LIST_HEAD (&dev_priv->rps.mmioflips.link); dev_priv->pm.suspended = false; +atomic_set (&dev_priv->pm.wakeref_count,0 ); }
drivers/gpu/drm/i915/intel_runtime_pm.c +6 -0
@@ -2236,6 +2236,8 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;pm_runtime_get_sync (device); + +atomic_inc (&dev_priv->pm.wakeref_count);assert_rpm_wakelock_held (dev_priv); }
@@ -2263,6 +2265,8 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)assert_rpm_wakelock_held (dev_priv);pm_runtime_get_noresume (device); + +atomic_inc (&dev_priv->pm.wakeref_count); }/**
@@ -2278,6 +2282,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +atomic_dec (&dev_priv->pm.wakeref_count); +pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device); }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/10] drm/i915: add support for checking if we hold an RPM reference
Quoted 8 lines · Imre Deak
Atm, we assert that the device is not suspended until the point when the device is truly put to a suspended state. This is fine, but we can catch more problems if we check that RPM refcount is non-zero. After that one drops to zero we shouldn't access the device any more, even if the actual device suspend may be delayed. Change
assert_rpm_wakelock_held()accordingly to check for a non-zero RPM refcount in addition to the current device-not-suspended check.
Quoted 15 lines
For the new asserts to work we need to annotate every place explicitly in the code where we expect that the device is powered. The places where we only assume this, but may not hold an RPM reference:
- driver load
We assume the device to be powered until we enable RPM. Make this explicit by taking an RPM reference around the load function.
- system and runtime sudpend/resume handlers
These handlers are called when the RPM reference becomes 0 and know the exact point after which the device can get powered off. Disable the RPM-reference-held check for their duration.
- the IRQ, hangcheck and RPS work handlers
These handlers are flushed in the system/runtime suspend handler before the device is powered off, so it's guaranteed that they won't run while the device is powered off even though they don't hold any RPM reference. Disable the RPM-reference-held check for their duration.
My current thinking is that the hangcheck/RPS tasks are wrong - and that we do actually have explicit wakerefs that should cover their lifetimes (but we fail to actually terminate them when we drop the associated wakeref).
With respect to the current state (cancelling the work in rpm_suspend), the assert disabling is correct, but I think we should be indicating that we papering over a "bug" more strongly.
i.e. something like DISABLE_RPM_WAKEREF_ASSERT();
-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 07/10] drm/i915: add support for checking if we hold an RPM reference
Quoted 43 lines · Chris Wilson
Quoted 26 lines · Imre Deak
Atm, we assert that the device is not suspended until the point when the
device is truly put to a suspended state. This is fine, but we can catch
more problems if we check that RPM refcount is non-zero. After that one
drops to zero we shouldn't access the device any more, even if the actual
device suspend may be delayed. Changeassert_rpm_wakelock_held()accordingly to check for a non-zero RPM refcount in addition to the current device-not-suspended check.For the new asserts to work we need to annotate every place explicitly in
the code where we expect that the device is powered. The places where we
only assume this, but may not hold an RPM reference:
- driver load
We assume the device to be powered until we enable RPM. Make this explicit by taking an RPM reference around the load function.
- system and runtime sudpend/resume handlers
These handlers are called when the RPM reference becomes 0 and know the
exact point after which the device can get powered off. Disable the
RPM-reference-held check for their duration.Quoted 8 lines
- the IRQ, hangcheck and RPS work handlers
These handlers are flushed in the system/runtime suspend handler before the device is powered off, so it's guaranteed that they won't
run while the device is powered off even though they don't hold any
RPM reference. Disable the RPM-reference-held check for their duration.My current thinking is that the hangcheck/RPS tasks are wrong - and that
we do actually have explicit wakerefs that should cover their lifetimes
(but we fail to actually terminate them when we drop the associated wakeref).
Quoted 6 lines
With respect to the current state (cancelling the work in
rpm_suspend),
the assert disabling is correct, but I think we should be indicating that we papering over a "bug" more strongly.i.e. something like
DISABLE_RPM_WAKEREF_ASSERT();
But the other cases are still legitimate, so we'd keep the lower case name for those and define the above macro as an alias simply to emphasize the difference?
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/10] drm/i915: add support for checking if we hold an RPM reference
Quoted 13 lines · Imre Deak
Quoted 12 lines · Chris Wilson
My current thinking is that the hangcheck/RPS tasks are wrong - and that
we do actually have explicit wakerefs that should cover their lifetimes
(but we fail to actually terminate them when we drop the associated wakeref).With respect to the current state (cancelling the work in
rpm_suspend),
the assert disabling is correct, but I think we should be indicating that we papering over a "bug" more strongly.
Quoted 5 lines
Quoted 1 line
i.e. something like
DISABLE_RPM_WAKEREF_ASSERT();But the other cases are still legitimate, so we'd keep the lower case name for those and define the above macro as an alias simply to emphasize the difference?
Yes. If you could put it in <blink> tags that would be a bonus. -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 v5 7/10 drm/i915: add support for checking if we hold an RPM reference
In reply to Imre DeakAtm, we assert that the device is not suspended until the point when the device is truly put to a suspended state. This is fine, but we can catch more problems if we check that RPM refcount is non-zero. After that one drops to zero we shouldn't access the device any more, even if the actual device suspend may be delayed. Change assert_rpm_wakelock_held() accordingly to check for a non-zero RPM refcount in addition to the current device-not-suspended check.
For the new asserts to work we need to annotate every place explicitly in the code where we expect that the device is powered. The places where we only assume this, but may not hold an RPM reference:
- driver load
We assume the device to be powered until we enable RPM. Make this explicit by taking an RPM reference around the load function.
- system and runtime sudpend/resume handlers
These handlers are called when the RPM reference becomes 0 and know the exact point after which the device can get powered off. Disable the RPM-reference-held check for their duration.
- the IRQ, hangcheck and RPS work handlers
These handlers are flushed in the system/runtime suspend handler before the device is powered off, so it's guaranteed that they won't run while the device is powered off even though they don't hold any RPM reference. Disable the RPM-reference-held check for their duration.
In all these cases we still check that the device is not suspended. These explicit annotations also have the positive side effect of documenting our assumptions better.
This caught additional WARNs from the atomic modeset path, those should be fixed separately.
v2:
- remove the redundant HAS_RUNTIME_PM check (moved to patch 1) (Ville) v3:
- use a new dedicated RPM wakelock refcount to also catch cases where our own RPM get/put functions were not called (Chris)
- assert also that the new RPM wakelock refcount is 0 in the RPM suspend handler (Chris)
- change the assert error message to be more meaningful (Chris)
- prevent false assert errors and check that the RPM wakelock is 0 in the RPM resume handler too
- prevent false assert errors in the hangcheck work too
- add a device not suspended assert check to the hangcheck work v4:
- rename disable/enable_rpm_asserts to disable/enable_rpm_wakeref_asserts and wakelock_count to wakeref_count
- disable the wakeref asserts in the IRQ handlers and RPS work too
- update/clarify commit message
v5:
- mark places we plan to change to use proper RPM refcounting with separate DISABLE/ENABLE_RPM_WAKEREF_ASSERTS aliases (Chris)
--- drivers/gpu/drm/i915/i915_dma.c | 7 +++ drivers/gpu/drm/i915/i915_drv.c | 39 +++++++++++++++-- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_irq.c | 75 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 49 +++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 + drivers/gpu/drm/i915/intel_runtime_pm.c | 6 +++ 7 files changed, 168 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +7 -0
@@ -896,6 +896,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)intel_pm_setup (dev); +intel_runtime_pm_get (dev_priv); +intel_display_crc_init (dev);i915_dump_device_info (dev_priv);
@@ -1085,6 +1087,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)i915_audio_component_init (dev_priv); +intel_runtime_pm_put (dev_priv); +return 0 ; out_power_well:
@@ -1120,6 +1124,9 @@ free_priv:kmem_cache_destroy (dev_priv->requests);kmem_cache_destroy (dev_priv->vmas);kmem_cache_destroy (dev_priv->objects); + +intel_runtime_pm_put (dev_priv); +kfree (dev_priv);return ret; }
drivers/gpu/drm/i915/i915_drv.c +35 -4
@@ -580,6 +580,8 @@ static int i915_drm_suspend(struct drm_device *dev) dev_priv->modeset_restore =MODESET_SUSPENDED ;mutex_unlock (&dev_priv->modeset_restore_lock); +disable_rpm_wakeref_asserts (dev_priv); +/* We do a lot of poking in a lot of registers, make sure they work * properly. */ intel_display_set_init_power (dev_priv, true);
@@ -592,7 +594,7 @@ static int i915_drm_suspend(struct drm_device *dev)if (error) {dev_err (&dev->pdev->dev,"GEM idle failed, resume might fail\n" ); -return error; + goto out; }intel_guc_suspend (dev);
@@ -635,7 +637,10 @@ static int i915_drm_suspend(struct drm_device *dev)if (HAS_CSR (dev_priv))flush_work (&dev_priv->csr.work); -return 0 ; +out: +enable_rpm_wakeref_asserts (dev_priv); + +return error; }static int i915_drm_suspend_late (struct drm_device *drm_dev,bool hibernation)
@@ -644,6 +649,8 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation)bool fw_csr;int ret; +disable_rpm_wakeref_asserts (dev_priv); + fw_csr =suspend_to_idle (dev_priv) && dev_priv->csr.dmc_payload;/* * In case of firmware assisted context save/restore don't manually
@@ -662,7 +669,7 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation)if (!fw_csr)intel_power_domains_init_hw (dev_priv, true); -return ret; + goto out; }pci_disable_device (drm_dev->pdev);
@@ -683,7 +690,10 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation) dev_priv->suspended_to_idle =suspend_to_idle (dev_priv); -return 0 ; +out: +enable_rpm_wakeref_asserts (dev_priv); + +return ret; }int i915_suspend_switcheroo (struct drm_device *dev,pm_message_t state)
@@ -714,6 +724,8 @@ static int i915_drm_resume(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +disable_rpm_wakeref_asserts (dev_priv); +mutex_lock (&dev->struct_mutex);i915_gem_restore_gtt_mappings (dev);mutex_unlock (&dev->struct_mutex);
@@ -778,6 +790,8 @@ static int i915_drm_resume(struct drm_device *dev)drm_kms_helper_poll_enable (dev); +enable_rpm_wakeref_asserts (dev_priv); +return 0 ; }
@@ -802,6 +816,8 @@ static int i915_drm_resume_early(struct drm_device *dev)pci_set_master (dev->pdev); +disable_rpm_wakeref_asserts (dev_priv); +if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv)) ret =vlv_resume_prepare (dev_priv, false);if (ret)
@@ -823,6 +839,8 @@ static int i915_drm_resume_early(struct drm_device *dev) out: dev_priv->suspended_to_idle = false; +enable_rpm_wakeref_asserts (dev_priv); +return ret; }
@@ -1455,6 +1473,9 @@ static int intel_runtime_suspend(struct device *device)return -EAGAIN ; } + +disable_rpm_wakeref_asserts (dev_priv); +/* * We are safe here against re-faults, since the fault handler takes * an RPM reference.
@@ -1474,10 +1495,15 @@ static int intel_runtime_suspend(struct device *device)DRM_ERROR ("Runtime suspend failed, disabling it (%d)\n" , ret);intel_runtime_pm_enable_interrupts (dev_priv); +enable_rpm_wakeref_asserts (dev_priv); +return ret; }intel_uncore_forcewake_reset (dev, false); + +enable_rpm_wakeref_asserts (dev_priv); +WARN_ON_ONCE (atomic_read (&dev_priv->pm.wakeref_count)); dev_priv->pm.suspended = true;/*
@@ -1521,6 +1547,9 @@ static int intel_runtime_resume(struct device *device)DRM_DEBUG_KMS ("Resuming device\n" ); +WARN_ON_ONCE (atomic_read (&dev_priv->pm.wakeref_count)); +disable_rpm_wakeref_asserts (dev_priv); +intel_opregion_notify_adapter (dev,PCI_D0 ); dev_priv->pm.suspended = false;
@@ -1555,6 +1584,8 @@ static int intel_runtime_resume(struct device *device)intel_enable_gt_powersave (dev); +enable_rpm_wakeref_asserts (dev_priv); +if (ret)DRM_ERROR ("Runtime resume failed, disabling it (%d)\n" , ret);else
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1602,6 +1602,7 @@ struct skl_wm_level {* For more, read the Documentation/power/runtime_pm.txt. */ struct i915_runtime_pm { +atomic_t wakeref_count;bool suspended;bool irqs_enabled; };
drivers/gpu/drm/i915/i915_irq.c +69 -6
207 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +49 -0
57 lines not on this page · raw message
drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -7247,4 +7247,5 @@ void intel_pm_setup(struct drm_device *dev)INIT_LIST_HEAD (&dev_priv->rps.mmioflips.link); dev_priv->pm.suspended = false; +atomic_set (&dev_priv->pm.wakeref_count,0 ); }
drivers/gpu/drm/i915/intel_runtime_pm.c +6 -0
@@ -2236,6 +2236,8 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;pm_runtime_get_sync (device); + +atomic_inc (&dev_priv->pm.wakeref_count);assert_rpm_wakelock_held (dev_priv); }
@@ -2263,6 +2265,8 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)assert_rpm_wakelock_held (dev_priv);pm_runtime_get_noresume (device); + +atomic_inc (&dev_priv->pm.wakeref_count); }/**
@@ -2278,6 +2282,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +atomic_dec (&dev_priv->pm.wakeref_count); +pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device); }
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 8/10 drm/i915: check that we hold an RPM wakelock ref before we put it
In reply to Imre Deakv2-v3:
- unchanged
v4:
- keep the corresponding check in the get helper (Chris)
--- drivers/gpu/drm/i915/intel_runtime_pm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/intel_runtime_pm.c +1 -0
@@ -2282,6 +2282,7 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +assert_rpm_wakelock_held (dev_priv);atomic_dec (&dev_priv->pm.wakeref_count);pm_runtime_mark_last_busy (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH 08/10] drm/i915: check that we hold an RPM wakelock ref before we put it
Quoted 4 lines · Imre Deak
v2-v3:
- unchanged
v4:
- keep the corresponding check in the get helper (Chris)
This is put helper you patched, so I think the above message is incorrect.
Regards, Joonas
Quoted 20 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/intel_runtime_pm.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/i915/intel_runtime_pm.c +1
-0@@ -2282,6 +2282,7 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct drm_device *dev = dev_priv->dev;struct device *device = &dev->pdev->dev; +assert_rpm_wakelock_held (dev_priv);atomic_dec (&dev_priv->pm.wakeref_count);
pm_runtime_mark_last_busy(device);
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/10] drm/i915: check that we hold an RPM wakelock ref before we put it
Quoted 8 lines · Joonas Lahtinen
Quoted 4 lines · Imre Deak
v2-v3:
- unchanged
v4:
- keep the corresponding check in the get helper (Chris)This is put helper you patched, so I think the above message is incorrect.
It is referring to a chunk no longer in the patch. :) -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 08/10] drm/i915: check that we hold an RPM wakelock ref before we put it
Quoted 11 lines · Chris Wilson
Quoted 8 lines · Joonas Lahtinen
Quoted 4 lines · Imre Deak
v2-v3:
- unchanged
v4:
- keep the corresponding check in the get helper (Chris)This is put helper you patched, so I think the above message is incorrect.
It is referring to a chunk no longer in the patch. :)
Yes, in v1 I removed an assert from intel_runtime_pm_get(), which was reinstated in v4:
http://lists.freedesktop.org/archives/intel-gfx/2015-November/080048.html
Quoted 1 line
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 9/10 drm/i915: add support for checking RPM atomic sections
In reply to Imre DeakIn some cases we want to check whether we hold an RPM wakelock reference for the whole duration of a sequence. To achieve this add a new RPM atomic sequence counter that we increment any time the wakelock refcount drops to zero. Check whether the sequence number stays the same during the atomic section and that we hold the wakelock at the beginning of the section.
Motivated by Chris.
v2-v3:
- unchanged
v4:
- swap the order of atomic_read() and assert_rpm_wakelock_held() in assert_rpm_atomic_begin() to avoid race
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_drv.h | 17 +++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 + drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1603,6 +1603,7 @@ struct skl_wm_level {*/ struct i915_runtime_pm {atomic_t wakeref_count; +atomic_t atomic_seq;bool suspended;bool irqs_enabled; };
drivers/gpu/drm/i915/intel_drv.h +17 -0
@@ -1446,6 +1446,23 @@ assert_rpm_wakelock_held(struct drm_i915_private *dev_priv) "RPM wakelock ref not held during HW access"); } +static inline int +assert_rpm_atomic_begin (struct drm_i915_private *dev_priv) +{ +int seq =atomic_read (&dev_priv->pm.atomic_seq); + +assert_rpm_wakelock_held (dev_priv); + +return seq; +} + +static inline void +assert_rpm_atomic_end (struct drm_i915_private *dev_priv,int begin_seq) +{ +WARN_ONCE (atomic_read (&dev_priv->pm.atomic_seq) != begin_seq, +"HW access outside of RPM atomic section\n" ); +} +/** * disable_rpm_wakeref_asserts - disable the RPM assert checks * @dev_priv: i915 device instance
drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -7248,4 +7248,5 @@ void intel_pm_setup(struct drm_device *dev) dev_priv->pm.suspended = false;atomic_set (&dev_priv->pm.wakeref_count,0 ); +atomic_set (&dev_priv->pm.atomic_seq,0 ); }
drivers/gpu/drm/i915/intel_runtime_pm.c +2 -1
@@ -2283,7 +2283,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;assert_rpm_wakelock_held (dev_priv); -atomic_dec (&dev_priv->pm.wakeref_count); +if (atomic_dec_and_test (&dev_priv->pm.wakeref_count)) +atomic_inc (&dev_priv->pm.atomic_seq);pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/10] drm/i915: add support for checking RPM atomic sections
Quoted 12 lines · Imre Deak
In some cases we want to check whether we hold an RPM wakelock reference
for the whole duration of a sequence. To achieve this add a new RPM atomic sequence
counter that we increment any time the wakelock refcount drops to zero.
Check whether the sequence number stays the same during the atomic section and that we hold the wakelock at the beginning of the section.Motivated by Chris.
Quoted 8 lines
v2-v3:
- unchanged
v4:
- swap the order ofatomic_read()andassert_rpm_wakelock_held()inassert_rpm_atomic_begin()to avoid raceSigned-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]> (v3)
Quoted 79 lines
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_drv.h | 17 +++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 + drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -1603,6 +1603,7 @@ struct skl_wm_level {*/ struct i915_runtime_pm {atomic_t wakeref_count; +atomic_t atomic_seq;bool suspended;bool irqs_enabled; };drivers/gpu/drm/i915/intel_drv.h +17
-0@@ -1446,6 +1446,23 @@ assert_rpm_wakelock_held(struct drm_i915_private *dev_priv) "RPM wakelock ref not held during HW access"); } +static inline int +assert_rpm_atomic_begin (struct drm_i915_private *dev_priv) +{ +int seq =atomic_read (&dev_priv->pm.atomic_seq); + +assert_rpm_wakelock_held (dev_priv); + +return seq; +} + +static inline void +assert_rpm_atomic_end (struct drm_i915_private *dev_priv,int begin_seq) +{ +WARN_ONCE (atomic_read (&dev_priv->pm.atomic_seq) != begin_seq, +"HW access outside of RPM atomic section\n" ); +} +/**
*disable_rpm_wakeref_asserts- disable the RPM assert checks
* @dev_priv: i915 device instancedrivers/gpu/drm/i915/intel_pm.c +1
-0@@ -7248,4 +7248,5 @@ void intel_pm_setup(struct drm_device *dev) dev_priv->pm.suspended = false;atomic_set (&dev_priv->pm.wakeref_count,0 ); +atomic_set (&dev_priv->pm.atomic_seq,0 ); }drivers/gpu/drm/i915/intel_runtime_pm.c +2
-1@@ -2283,7 +2283,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;assert_rpm_wakelock_held (dev_priv); -atomic_dec (&dev_priv->pm.wakeref_count); +if (atomic_dec_and_test (&dev_priv->pm.wakeref_count)) +atomic_inc (&dev_priv->pm.atomic_seq);pm_runtime_mark_last_busy (device);
pm_runtime_put_autosuspend(device);
Signature · 8 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/10] drm/i915: add support for checking RPM atomic sections
In reply to Imre DeakQuoted 8 lines · Imre Deak
In some cases we want to check whether we hold an RPM wakelock reference for the whole duration of a sequence. To achieve this add a new RPM atomic sequence counter that we increment any time the wakelock refcount drops to zero. Check whether the sequence number stays the same during the atomic section and that we hold the wakelock at the beginning of the section.
Motivated by Chris.
Quoted 8 lines
v2-v3:
- unchanged
v4:
- swap the order ofatomic_read()andassert_rpm_wakelock_held()inassert_rpm_atomic_begin()to avoid raceSigned-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]> (v3)
Can we employ lockdep for some of this? In general lockdep doesn't mesh with rpm references, since rpm references can be transferred between processes. And lockdep doesn't like that.
But in many cases, and this one here sounds like one, we don't do that. And those cases could be annotated/validated with the help of lockdep. The bonus of lockdep is that we could then also tell lockdep that the rpm suspend/resume functionsa acquire this lock context, which would catch bugs like mutex_lock(dev->struct_mutex); before rpm_get().
Just a thought really.
Quoted 78 lines
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_drv.h | 17 +++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 + drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -1603,6 +1603,7 @@ struct skl_wm_level {*/ struct i915_runtime_pm {atomic_t wakeref_count; +atomic_t atomic_seq;bool suspended;bool irqs_enabled; };drivers/gpu/drm/i915/intel_drv.h +17
-0@@ -1446,6 +1446,23 @@ assert_rpm_wakelock_held(struct drm_i915_private *dev_priv) "RPM wakelock ref not held during HW access"); } +static inline int +assert_rpm_atomic_begin (struct drm_i915_private *dev_priv) +{ +int seq =atomic_read (&dev_priv->pm.atomic_seq); + +assert_rpm_wakelock_held (dev_priv); + +return seq; +} + +static inline void +assert_rpm_atomic_end (struct drm_i915_private *dev_priv,int begin_seq) +{ +WARN_ONCE (atomic_read (&dev_priv->pm.atomic_seq) != begin_seq, +"HW access outside of RPM atomic section\n" ); +} +/** * disable_rpm_wakeref_asserts - disable the RPM assert checks * @dev_priv: i915 device instance drivers/gpu/drm/i915/intel_pm.c +1
-0@@ -7248,4 +7248,5 @@ void intel_pm_setup(struct drm_device *dev) dev_priv->pm.suspended = false;atomic_set (&dev_priv->pm.wakeref_count,0 ); +atomic_set (&dev_priv->pm.atomic_seq,0 ); }drivers/gpu/drm/i915/intel_runtime_pm.c +2
-1@@ -2283,7 +2283,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)struct device *device = &dev->pdev->dev;assert_rpm_wakelock_held (dev_priv); -atomic_dec (&dev_priv->pm.wakeref_count); +if (atomic_dec_and_test (&dev_priv->pm.wakeref_count)) +atomic_inc (&dev_priv->pm.atomic_seq);pm_runtime_mark_last_busy (device);pm_runtime_put_autosuspend (device);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 09/10] drm/i915: add support for checking RPM atomic sections
Quoted 37 lines · Daniel Vetter
Quoted 12 lines · Imre Deak
In some cases we want to check whether we hold an RPM wakelock reference
for the whole duration of a sequence. To achieve this add a new RPM atomic sequence
counter that we increment any time the wakelock refcount drops to zero.
Check whether the sequence number stays the same during the atomic section and that we hold the wakelock at the beginning of the section.Motivated by Chris.
Quoted 8 lines
v2-v3:
- unchanged
v4:
- swap the order ofatomic_read()andassert_rpm_wakelock_held()inassert_rpm_atomic_begin()to avoid raceSigned-off-by Imre Deak <[email protected]>Reviewed-by Chris Wilson <[email protected]> (v3)Can we employ lockdep for some of this? In general lockdep doesn't mesh
with rpm references, since rpm references can be transferred between processes. And lockdep doesn't like that.But in many cases, and this one here sounds like one, we don't do that.
And those cases could be annotated/validated with the help of lockdep.
The bonus of lockdep is that we could then also tell lockdep that the rpm
suspend/resume functionsa acquire this lock context, which would catch
bugs likemutex_lock(dev->struct_mutex); beforerpm_get().
Quoted 1 line
Just a thought really.
Yes, as I mentioned I also played with the idea and it could be done by separating the RPM wakelock users into "prolonged" and short time users. Yea, couldn't think of a better name. I explained what I mean in the top three patch of:
https://github.com/ideak/linux/commits/rpm-lockdep-annotations
But I would still need to do more testing with this, making sure the annotations work as expected, in particular that I call lock_acquire() with the proper parameters. So until that we could use this simpler check that could reveal some issues already now.
--Imre
Quoted 82 lines
Quoted 82 lines
---
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_drv.h | 17 +++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 1 +drivers/gpu/drm/i915/intel_runtime_pm.c| 3 ++-4 files changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -1603,6 +1603,7 @@ struct skl_wm_level {*/ struct i915_runtime_pm { atomic_t wakeref_count; +atomic_t atomic_seq; bool suspended; bool irqs_enabled; };drivers/gpu/drm/i915/intel_drv.h +0
-0@@ -1446,6 +1446,23 @@ assert_rpm_wakelock_held(struct drm_i915_private *dev_priv) "RPM wakelock ref not held during HW access"); }drivers/gpu/drm/i915/intel_drv.h +12
-0+static inline int +assert_rpm_atomic_begin (struct drm_i915_private *dev_priv) +{ +int seq =atomic_read (&dev_priv->pm.atomic_seq); + +assert_rpm_wakelock_held (dev_priv); + +return seq; +} + +static inline void +assert_rpm_atomic_end(struct drm_i915_private *dev_priv, int
begin_seq)drivers/gpu/drm/i915/intel_drv.h +2
-0+{ + WARN_ONCE(atomic_read(&dev_priv->pm.atomic_seq) !=
begin_seq,drivers/gpu/drm/i915/intel_drv.h +3
-0+ "HW access outside of RPM atomic section\n"); +} +/**
*disable_rpm_wakeref_asserts- disable the RPM assert checks
* @dev_priv: i915 device instancedrivers/gpu/drm/i915/intel_pm.c +0
-0@@ -7248,4 +7248,5 @@ void intel_pm_setup(struct drm_device *dev)
dev_priv->pm.suspended= false;atomic_set(&dev_priv->pm.wakeref_count, 0);drivers/gpu/drm/i915/intel_pm.c +1
-0+atomic_set (&dev_priv->pm.atomic_seq,0 );}
drivers/gpu/drm/i915/intel_runtime_pm.c +0
-0@@ -2283,7 +2283,8 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv) struct device *device = &dev->pdev->dev;
assert_rpm_wakelock_held(dev_priv);drivers/gpu/drm/i915/intel_runtime_pm.c +2
-1-atomic_dec (&dev_priv->pm.wakeref_count); +if (atomic_dec_and_test (&dev_priv->pm.wakeref_count)) +atomic_inc (&dev_priv->pm.atomic_seq);
pm_runtime_mark_last_busy(device);
pm_runtime_put_autosuspend(device);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 v4 10/10 drm/i915: check that we are in an RPM atomic section in GGTT PTE updaters
In reply to Imre DeakThe device should be on for the whole duration of the update, so check for this.
v2:
- use the existing dev_priv directly everywhere (Ville) v3:
- check also that we are in an RPM atomic section (Chris)
- add the assert to i915_ggtt_insert_entries/clear_range too (Chris)
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +33 -0
@@ -2351,6 +2351,9 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,int i =0 ;struct sg_page_iter sg_iter;dma_addr_t addr =0 ;/* shut up gcc */ +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv);for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr = sg_dma_address(sg_iter.sg) +
@@ -2377,6 +2380,8 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,*/ I915_WRITE (GFX_FLSH_CNTL_GEN6 ,GFX_FLSH_CNTL_EN );POSTING_READ (GFX_FLSH_CNTL_GEN6 ); + +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); }/*
@@ -2397,6 +2402,9 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,int i =0 ;struct sg_page_iter sg_iter;dma_addr_t addr =0 ; +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv);for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter);
@@ -2421,6 +2429,8 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,*/ I915_WRITE (GFX_FLSH_CNTL_GEN6 ,GFX_FLSH_CNTL_EN );POSTING_READ (GFX_FLSH_CNTL_GEN6 ); + +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); } static void gen8_ggtt_clear_range(struct i915_address_space *vm,
@@ -2435,6 +2445,9 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm, (gen8_pte_t __iomem *) dev_priv->gtt.gsm + first_entry;const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv); if (WARN(num_entries > max_entries, "First entry = %d; Num entries = %d (max=%d)\n",
@@ -2447,6 +2460,8 @@ static void gen8_ggtt_clear_range(struct i915_address_space *vm,for (i =0 ; i < num_entries; i++)gen8_set_pte (>t_base[i], scratch_pte);readl (gtt_base); + +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); } static void gen6_ggtt_clear_range(struct i915_address_space *vm,
@@ -2461,6 +2476,9 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm, (gen6_pte_t __iomem *) dev_priv->gtt.gsm + first_entry;const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv); if (WARN(num_entries > max_entries, "First entry = %d; Num entries = %d (max=%d)\n",
@@ -2473,6 +2491,8 @@ static void gen6_ggtt_clear_range(struct i915_address_space *vm,for (i =0 ; i < num_entries; i++)iowrite32 (scratch_pte, >t_base[i]);readl (gtt_base); + +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); } static void i915_ggtt_insert_entries(struct i915_address_space *vm,
@@ -2480,11 +2500,17 @@ static void i915_ggtt_insert_entries(struct i915_address_space *vm,uint64_t start, enum i915_cache_level cache_level, u32 unused) { + struct drm_i915_private *dev_priv = vm->dev->dev_private;unsigned int flags = (cache_level ==I915_CACHE_NONE ) ?AGP_USER_MEMORY :AGP_USER_CACHED_MEMORY ; +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv);intel_gtt_insert_sg_entries (pages, start >>PAGE_SHIFT , flags); +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); + } static void i915_ggtt_clear_range(struct i915_address_space *vm,
@@ -2492,9 +2518,16 @@ static void i915_ggtt_clear_range(struct i915_address_space *vm, uint64_t length, bool unused) { +struct drm_i915_private *dev_priv = vm->dev->dev_private;unsigned first_entry = start >>PAGE_SHIFT ;unsigned num_entries = length >>PAGE_SHIFT ; +int rpm_atomic_seq; + + rpm_atomic_seq =assert_rpm_atomic_begin (dev_priv); +intel_gtt_clear_range (first_entry, num_entries); + +assert_rpm_atomic_end (dev_priv, rpm_atomic_seq); } static int ggtt_bind_vma(struct i915_vma *vma,
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · Imre Deak
This is v4 of [1]. It has the following changes:
- fix module reload that got broken in v3 due to removal ofHAS_RUNTIME_PM(added patch 1-3 + revised patch 4)
- disable the wakeref asserts in the IRQ handlers and RPS work too (revised patch 7)
[1] http://lists.freedesktop.org/archives/intel-gfx/2015-November/080005.html
Thanks for all the reviews, I pushed the patchset to dinq.
Quoted 18 lines
Imre Deak (10):
drm/i915: clarify comment about mandatory RPM put/get during driver load/unload
drm/i915: disable power well support on platforms without runtime PM support
drm/i915: refactor RPM disabling due to RC6 being disabled drm/i915: removeHAS_RUNTIME_PMcheck from RPM get/put/assert helpers drm/i915: addassert_rpm_wakelock_heldhelper
drm/i915: useassert_rpm_wakelock_heldinstead of opencoding it drm/i915: add support for checking if we hold an RPM reference drm/i915: check that we hold an RPM wakelock ref before we put it drm/i915: add support for checking RPM atomic sections drm/i915: check that we are in an RPM atomic section in GGTT PTE updatersdrivers/gpu/drm/i915/i915_dma.c | 7 ++++ drivers/gpu/drm/i915/i915_drv.c | 39 ++++++++++++++++-- drivers/gpu/drm/i915/i915_drv.h | 2 +
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c | 33 +++++++++++++++ drivers/gpu/drm/i915/i915_irq.c | 73 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_drv.h | 72 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++
drivers/gpu/drm/i915/intel_runtime_pm.c| 57 ++++++++++++------------- drivers/gpu/drm/i915/intel_uncore.c | 23 ++++-------9 files changed, 270 insertions(+), 53 deletions(-)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx