fix VLV S4 suspend/resume, unify S3/S4 handlers
Subsystems (2)
cover fix VLV S4 suspend/resume, unify S3/S4 handlers
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
I smoke tested this on BDW, HSW, VLV (BYT-M), IVB, GEN45.
Imre Deak (16):
drm/i915: vlv: fix gunit HW state corruption during S4 suspend drm/i915: remove dead code from legacy suspend handler drm/i915: factor out i915_drm_suspend_late
drm/i915: unify legacy S3 suspend and S4 freeze handlers drm/i915: propagate error from legacy resume handler drm/i915: vlv: fix switcheroo/legacy suspend/resume drm/i915: fix S4 suspend while switcheroo state is off drm/i915: remove unused restore_gtt_mappings optimization during
suspend
drm/i915: check for GT faults during S3 resume and S4 restore too drm/i915: enable output polling during S4 thaw drm/i915: disable/re-enable PCI device around S4 freeze/thaw drm/i915: unify S3 and S4 suspend/resume handlers drm/i915: sanitize suspend/resume helper function names drm/i915: add poweroff_late handler
drm/i915: unify switcheroo and legacy suspend/resume handlers drm/i915: add comments on what stage a given PM handler is called
drivers/gpu/drm/i915/i915_dma.c | 4 +- drivers/gpu/drm/i915/i915_drv.c | 185 +++++++++++++++------------------------- drivers/gpu/drm/i915/i915_drv.h | 4 +- 3 files changed, 74 insertions(+), 119 deletions(-)
Signature · 1 line
1.8.4
PATCH 1/16 drm/i915: vlv: fix gunit HW state corruption during S4 suspend
During S4 freeze we don't call intel_suspend_complete(), which would save the gunit HW state, but during S4 thaw/restore events we call intel_resume_prepare() which restores it, thus ending up in a corrupted HW state.
Fix this by calling intel_suspend_complete() from the corresponding freeze_late event handler.
The issue was introduced in
commit 016970beb05da6285c2f3ed2bee1c676cb75972e
Author: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530
--- drivers/gpu/drm/i915/i915_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +10 -0
@@ -987,6 +987,15 @@ static int i915_pm_freeze(struct device *dev)return i915_drm_freeze (drm_dev); } +static int i915_pm_freeze_late (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct drm_i915_private *dev_priv = drm_dev->dev_private; + +return intel_suspend_complete (dev_priv); +} +static int i915_pm_thaw_early (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);
@@ -1571,6 +1580,7 @@ static const struct dev_pm_ops i915_pm_ops = { .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, .freeze = i915_pm_freeze, + .freeze_late = i915_pm_freeze_late, .thaw_early = i915_pm_thaw_early, .thaw = i915_pm_thaw, .poweroff = i915_pm_poweroff,
Signature · 1 line
1.8.4
Re: [PATCH 01/16] drm/i915: vlv: fix gunit HW state corruption during S4 suspend
Quoted 1 line
From DPM documentation,
thaw_earlyshould undo actions byfreeze_late.
Can we move following snippet from thaw_early to thaw to comply with this?
intel_uncore_early_sanitize(dev, true);
intel_uncore_sanitize(dev);
intel_power_domains_init_hw(dev_priv);Quoted 47 lines · Imre Deak
During S4 freeze we don't call
intel_suspend_complete(), which would save the gunit HW state, but during S4 thaw/restore events we callintel_resume_prepare()which restores it, thus ending up in a corrupted HW state.Fix this by calling
intel_suspend_complete()from the correspondingfreeze_lateevent handler.The issue was introduced in
commit016970beb05da6285c2f3ed2bee1c676cb75972eAuthor: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530CC Sagar Kamble <[email protected]>Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/i915_drv.c +10
-0@@ -987,6 +987,15 @@ static int i915_pm_freeze(struct device *dev)return i915_drm_freeze (drm_dev); } +static int i915_pm_freeze_late (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct drm_i915_private *dev_priv = drm_dev->dev_private; + +return intel_suspend_complete (dev_priv); +} +static int i915_pm_thaw_early (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);@@ -1571,6 +1580,7 @@ static const struct dev_pm_ops i915_pm_ops = { .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, .freeze = i915_pm_freeze, + .freeze_late = i915_pm_freeze_late, .thaw_early = i915_pm_thaw_early, .thaw = i915_pm_thaw, .poweroff = i915_pm_poweroff,
Re: [PATCH 01/16] drm/i915: vlv: fix gunit HW state corruption during S4 suspend
The point of doing these in thaw_early is to work around an ordering issue wrt. to the hda driver, see the comment in i915_resume_early(). I don't see a problem of having them in thaw_early; if you meant that they lack the corresponding cleanup calls in freeze_late, it's just because they don't have any.
Quoted 58 lines · Sagar Arun Kamble
From DPM documentation,
thaw_earlyshould undo actions byfreeze_late. Can we move following snippet fromthaw_earlyto thaw to comply with this?intel_uncore_early_sanitize(dev, true); intel_uncore_sanitize(dev); intel_power_domains_init_hw(dev_priv);Quoted 47 lines · Imre Deak
During S4 freeze we don't call
intel_suspend_complete(), which would save the gunit HW state, but during S4 thaw/restore events we callintel_resume_prepare()which restores it, thus ending up in a corrupted HW state.Fix this by calling
intel_suspend_complete()from the correspondingfreeze_lateevent handler.The issue was introduced in
commit016970beb05da6285c2f3ed2bee1c676cb75972eAuthor: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530CC Sagar Kamble <[email protected]>Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/i915_drv.c +10
-0@@ -987,6 +987,15 @@ static int i915_pm_freeze(struct device *dev)return i915_drm_freeze (drm_dev); } +static int i915_pm_freeze_late (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct drm_i915_private *dev_priv = drm_dev->dev_private; + +return intel_suspend_complete (dev_priv); +} +static int i915_pm_thaw_early (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);@@ -1571,6 +1580,7 @@ static const struct dev_pm_ops i915_pm_ops = { .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, .freeze = i915_pm_freeze, + .freeze_late = i915_pm_freeze_late, .thaw_early = i915_pm_thaw_early, .thaw = i915_pm_thaw, .poweroff = i915_pm_poweroff,
Sagar Arun Kamble
Reviewed-byRe: [PATCH 01/16] drm/i915: vlv: fix gunit HW state corruption during S4 suspend
Thanks Imre.
Quoted 67 lines · Imre Deak
The point of doing these in
thaw_earlyis to work around an ordering issue wrt. to the hda driver, see the comment ini915_resume_early(). I don't see a problem of having them inthaw_early; if you meant that they lack the corresponding cleanup calls infreeze_late, it's just because they don't have any.Quoted 58 lines · Sagar Arun Kamble
From DPM documentation,
thaw_earlyshould undo actions byfreeze_late. Can we move following snippet fromthaw_earlyto thaw to comply with this?intel_uncore_early_sanitize(dev, true); intel_uncore_sanitize(dev); intel_power_domains_init_hw(dev_priv);Quoted 47 lines · Imre Deak
During S4 freeze we don't call
intel_suspend_complete(), which would save the gunit HW state, but during S4 thaw/restore events we callintel_resume_prepare()which restores it, thus ending up in a corrupted HW state.Fix this by calling
intel_suspend_complete()from the correspondingfreeze_lateevent handler.The issue was introduced in
commit016970beb05da6285c2f3ed2bee1c676cb75972eAuthor: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530CC Sagar Kamble <[email protected]>Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/i915_drv.c +10
-0@@ -987,6 +987,15 @@ static int i915_pm_freeze(struct device *dev)return i915_drm_freeze (drm_dev); } +static int i915_pm_freeze_late (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct drm_i915_private *dev_priv = drm_dev->dev_private; + +return intel_suspend_complete (dev_priv); +} +static int i915_pm_thaw_early (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);@@ -1571,6 +1580,7 @@ static const struct dev_pm_ops i915_pm_ops = { .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, .freeze = i915_pm_freeze, + .freeze_late = i915_pm_freeze_late, .thaw_early = i915_pm_thaw_early, .thaw = i915_pm_thaw, .poweroff = i915_pm_poweroff,
Re: [PATCH 01/16] drm/i915: vlv: fix gunit HW state corruption during S4 suspend
In reply to Imre DeakQuoted 8 lines · Imre Deak
During S4 freeze we don't call
intel_suspend_complete(), which would save the gunit HW state, but during S4 thaw/restore events we callintel_resume_prepare()which restores it, thus ending up in a corrupted HW state.Fix this by calling
intel_suspend_complete()from the correspondingfreeze_lateevent handler.
Quoted 7 lines
The issue was introduced in
commit016970beb05da6285c2f3ed2bee1c676cb75972eAuthor: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530CC Sagar Kamble <[email protected]>Signed-off-by Imre Deak <[email protected]>
Yep, pairs up with .thaw_early()/.restore_early(), which should take care of all the valid combinations of pm events.
Quoted 39 lines
--- drivers/gpu/drm/i915/i915_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpu/drm/i915/i915_drv.c +10
-0@@ -987,6 +987,15 @@ static int i915_pm_freeze(struct device *dev)return i915_drm_freeze (drm_dev); } +static int i915_pm_freeze_late (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct drm_i915_private *dev_priv = drm_dev->dev_private; + +return intel_suspend_complete (dev_priv); +} +static int i915_pm_thaw_early (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);@@ -1571,6 +1580,7 @@ static const struct dev_pm_ops i915_pm_ops = { .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, .freeze = i915_pm_freeze, + .freeze_late = i915_pm_freeze_late, .thaw_early = i915_pm_thaw_early, .thaw = i915_pm_thaw, .poweroff = i915_pm_poweroff,Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 2/16 drm/i915: remove dead code from legacy suspend handler
In reply to Imre DeakThe legacy DRM suspend logic (effective in UMS) doesn't handle any S4 thaw events so we don't need to care about it either. Only S3 suspend and S4 freeze events are handled. Leave an assert behind to be sure.
--- drivers/gpu/drm/i915/i915_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +3 -3
@@ -618,9 +618,9 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)return -ENODEV ; } -if (state.event ==PM_EVENT_PRETHAW ) -return 0 ; - +if (WARN_ON_ONCE (state.event !=PM_EVENT_SUSPEND && + state.event !=PM_EVENT_FREEZE )) +return -EINVAL ;if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ;
Signature · 1 line
1.8.4
Re: [PATCH 02/16] drm/i915: remove dead code from legacy suspend handler
Quoted 5 lines · Imre Deak
The legacy DRM suspend logic (effective in UMS) doesn't handle any S4 thaw events so we don't need to care about it either. Only S3 suspend and S4 freeze events are handled. Leave an assert behind to be sure.
Signed-off-by Imre Deak <[email protected]>
Looks correct.
Although it the lack of .thaw() means there's no error recovery when things go south. But this is UMS so who cares.
Quoted 28 lines
--- drivers/gpu/drm/i915/i915_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.c +3
-3@@ -618,9 +618,9 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)return -ENODEV ; } -if (state.event ==PM_EVENT_PRETHAW ) -return 0 ; - +if (WARN_ON_ONCE (state.event !=PM_EVENT_SUSPEND && + state.event !=PM_EVENT_FREEZE )) +return -EINVAL ;if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ;Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
Daniel Vetter
AppliedRe: [PATCH 02/16] drm/i915: remove dead code from legacy suspend handler
Quoted 5 lines · Ville Syrjälä
Quoted 4 lines · Imre Deak
The legacy DRM suspend logic (effective in UMS) doesn't handle any S4 thaw events so we don't need to care about it either. Only S3 suspend and S4 freeze events are handled. Leave an assert behind to be sure.
Quoted 8 lines
Quoted 1 line
Signed-off-by Imre Deak <[email protected]>Looks correct.
Although it the lack of .thaw() means there's no error recovery when things go south. But this is UMS so who cares.
Reviewed-by Ville Syrjälä <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 3/16 drm/i915: factor out i915_drm_suspend_late
In reply to Imre DeakThis is needed by an upcoming patch fixing the switcheroo/legacy suspend paths.
No functional change.
--- drivers/gpu/drm/i915/i915_drv.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +20 -12
@@ -608,6 +608,25 @@ static int i915_drm_freeze(struct drm_device *dev)return 0 ; } +static int i915_drm_suspend_late (struct drm_device *drm_dev) +{ +struct drm_i915_private *dev_priv = drm_dev->dev_private; +int ret; + + ret =intel_suspend_complete (dev_priv); + +if (ret) { +DRM_ERROR ("Suspend complete failed: %d\n" , ret); + +return ret; + } + +pci_disable_device (drm_dev->pdev); +pci_set_power_state (drm_dev->pdev, PCI_D3hot); + +return 0 ; +} +int i915_suspend (struct drm_device *dev,pm_message_t state) {int error;
@@ -931,8 +950,6 @@ static int i915_pm_suspend_late(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct drm_i915_private *dev_priv = drm_dev->dev_private; -int ret;/* * We have a suspedn ordering issue with the snd-hda driver also
@@ -946,16 +963,7 @@ static int i915_pm_suspend_late(struct device *dev)if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; - ret =intel_suspend_complete (dev_priv); - -if (ret) -DRM_ERROR ("Suspend complete failed: %d\n" , ret); -else { -pci_disable_device (pdev); -pci_set_power_state (pdev, PCI_D3hot); - } - -return ret; +return i915_drm_suspend_late (drm_dev); }static int i915_pm_resume_early (struct device *dev)
Signature · 1 line
1.8.4
PATCH 4/16 drm/i915: unify legacy S3 suspend and S4 freeze handlers
In reply to Imre Deaki915_suspend() is called from the DRM legacy S3 suspend/S4 freeze paths and the switcheroo suspend path. For switcheroo we only ever need to perform a full suspend (PM_EVENT_SUSPEND) and for the DRM legacy path we can handle the S4 freeze (PM_EVENT_FREEZE) the same way as S3 suspend. The only difference atm between suspend and freeze is that during freeze we don't disable the PCI device, but there is no reason why we can't do so. So unify the two cases to reduce complexity.
Note that for the DRM legacy case the thaw event is not handled, so we disable the display before creating the hibernation image and it won't get re-enabled until reboot. We could fix this leaving the display enabled for the image creation/writing (if we care enough about UMS), but this can be done as a follow-up.
--- drivers/gpu/drm/i915/i915_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +3 -5
@@ -648,11 +648,9 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (error)return error; -if (state.event ==PM_EVENT_SUSPEND ) { -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3hot);return 0 ; }
Signature · 1 line
1.8.4
Re: [PATCH 04/16] drm/i915: unify legacy S3 suspend and S4 freeze handlers
Quoted 8 lines · Imre Deak
i915_suspend()is called from the DRM legacy S3 suspend/S4 freeze paths and the switcheroo suspend path. For switcheroo we only ever need to perform a full suspend (PM_EVENT_SUSPEND) and for the DRM legacy path we can handle the S4 freeze (PM_EVENT_FREEZE) the same way as S3 suspend. The only difference atm between suspend and freeze is that during freeze we don't disable the PCI device, but there is no reason why we can't do so. So unify the two cases to reduce complexity.
Quoted 5 lines
Note that for the DRM legacy case the thaw event is not handled, so we disable the display before creating the hibernation image and it won't get re-enabled until reboot. We could fix this leaving the display enabled for the image creation/writing (if we care enough about UMS), but this can be done as a follow-up.
UMS doesn't even get compiled any more, please don't try to fix it ;-)
My plan is to garbage-collect it all around when 3.17 is out the door. -Daniel
Quoted 32 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.c +3
-5@@ -648,11 +648,9 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (error)return error; -if (state.event ==PM_EVENT_SUSPEND ) { -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3hot);return 0 ; }Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 04/16] drm/i915: unify legacy S3 suspend and S4 freeze handlers
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Imre Deak
i915_suspend()is called from the DRM legacy S3 suspend/S4 freeze paths and the switcheroo suspend path. For switcheroo we only ever need to perform a full suspend (PM_EVENT_SUSPEND) and for the DRM legacy path we can handle the S4 freeze (PM_EVENT_FREEZE) the same way as S3 suspend. The only difference atm between suspend and freeze is that during freeze we don't disable the PCI device, but there is no reason why we can't do so. So unify the two cases to reduce complexity.
Quoted 7 lines
Quoted 5 lines
Note that for the DRM legacy case the thaw event is not handled, so we disable the display before creating the hibernation image and it won't get re-enabled until reboot. We could fix this leaving the display enabled for the image creation/writing (if we care enough about UMS), but this can be done as a follow-up.
UMS doesn't even get compiled any more, please don't try to fix it ;-)
Ok. That reference above to UMS was only for a future possible fix, but then we can ignore it. There are some UMS (aka legacy s/r) related changes/fixes in this patchset too, but they are done alongside the switcheroo fixes, since in the end the two things are handled the same way.
--Imre
Quoted 31 lines
My plan is to garbage-collect it all around when 3.17 is out the door. -Daniel
Quoted 28 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.c +3
-5@@ -648,11 +648,9 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (error)return error; -if (state.event ==PM_EVENT_SUSPEND ) { -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - } +/* Shut down the device */ +pci_disable_device (dev->pdev); +pci_set_power_state (dev->pdev, PCI_D3hot);return 0 ; }Signature · 1 line
1.8.4
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 5/16 drm/i915: propagate error from legacy resume handler
In reply to Imre Deak--- drivers/gpu/drm/i915/i915_drv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +6 -3
@@ -789,10 +789,13 @@ int i915_resume(struct drm_device *dev)static int i915_resume_legacy (struct drm_device *dev) { -i915_resume_early (dev); -i915_resume (dev); +int ret; -return 0 ; + ret =i915_resume_early (dev); +if (ret) +return ret; + +return i915_resume (dev); }/**
Signature · 1 line
1.8.4
PATCH 6/16 drm/i915: vlv: fix switcheroo/legacy suspend/resume
In reply to Imre DeakDuring switcheroo/legacy suspend we don't call the suspend_late handler but when resuming afterwards we call resume_early. This happened to work so far, since suspend_late only disabled the PCI device. This changed in
commit 016970beb05da6285c2f3ed2bee1c676cb75972e
Author: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530
drm/i915: Sharing platform specific sequence between runtime and system susp
after which we also saved/restored the VLV Gunit HW state in suspend_late/resume_early. So now since we don't save the state during suspend a following resume will restore a corrupted state.
Fix this by calling the suspend_late handler during both switcheroo and legacy suspend.
--- drivers/gpu/drm/i915/i915_drv.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +9 -8
@@ -648,11 +648,7 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (error)return error; -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - -return 0 ; +return i915_drm_suspend_late (dev); }static int i915_drm_thaw_early (struct drm_device *dev)
@@ -769,7 +765,7 @@ static int i915_resume_early(struct drm_device *dev)return i915_drm_thaw_early (dev); } -int i915_resume (struct drm_device *dev) +static int i915_drm_resume (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;int ret;
@@ -795,7 +791,12 @@ static int i915_resume_legacy(struct drm_device *dev)if (ret)return ret; -return i915_resume (dev); +return i915_drm_resume (dev); +} + +int i915_resume (struct drm_device *dev) +{ +return i915_resume_legacy (dev); }/**
@@ -980,7 +981,7 @@ static int i915_pm_resume(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -return i915_resume (drm_dev); +return i915_drm_resume (drm_dev); }static int i915_pm_freeze (struct device *dev)
Signature · 1 line
1.8.4
Re: [PATCH 06/16] drm/i915: vlv: fix switcheroo/legacy suspend/resume
Quoted 72 lines · Imre Deak
During switcheroo/legacy suspend we don't call the
suspend_latehandler but when resuming afterwards we callresume_early. This happened to work so far, sincesuspend_lateonly disabled the PCI device. This changed incommit
016970beb05da6285c2f3ed2bee1c676cb75972eAuthor: Sagar Kamble <[email protected]> Date: Wed Aug 13 23:07:06 2014 +0530drm/i915: Sharing platform specific sequence between runtime and system susp
after which we also saved/restored the VLV Gunit HW state in suspend_late/resume_early. So now since we don't save the state during suspend a following resume will restore a corrupted state.
Fix this by calling the
suspend_latehandler during both switcheroo and legacy suspend.CC Sagar Kamble <[email protected]>Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_drv.c +9
-8@@ -648,11 +648,7 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (error)return error; -/* Shut down the device */ -pci_disable_device (dev->pdev); -pci_set_power_state (dev->pdev, PCI_D3hot); - -return 0 ; +return i915_drm_suspend_late (dev); }static int i915_drm_thaw_early (struct drm_device *dev)@@ -769,7 +765,7 @@ static int i915_resume_early(struct drm_device *dev)return i915_drm_thaw_early (dev); } -int i915_resume (struct drm_device *dev) +static int i915_drm_resume (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;int ret;@@ -795,7 +791,12 @@ static int i915_resume_legacy(struct drm_device *dev)if (ret)return ret; -return i915_resume (dev); +return i915_drm_resume (dev); +} + +int i915_resume (struct drm_device *dev) +{ +return i915_resume_legacy (dev); }/** @@ -980,7 +981,7 @@ static int i915_pm_resume(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -return i915_resume (drm_dev); +return i915_drm_resume (drm_dev); }static int i915_pm_freeze (struct device *dev)
PATCH 7/16 drm/i915: fix S4 suspend while switcheroo state is off
In reply to Imre DeakIf the device is suspended already through the switcheroo interface we shouldn't suspend it again. We have the corresponding check for S3 suspend already, add it for S4 freeze and poweroff too.
Note that there is still the problem that the resume path should also check for the switcheroo-off state and keep the device disabled or in case of S4 disable it. That is a separate issue, which is not addressed in this patchset.
--- drivers/gpu/drm/i915/i915_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +9 -0
@@ -994,6 +994,9 @@ static int i915_pm_freeze(struct device *dev)return -ENODEV ; } +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }
@@ -1003,6 +1006,9 @@ static int i915_pm_freeze_late(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);struct drm_i915_private *dev_priv = drm_dev->dev_private; +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return intel_suspend_complete (dev_priv); }
@@ -1027,6 +1033,9 @@ static int i915_pm_poweroff(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }
Signature · 1 line
1.8.4
Re: [PATCH 07/16] drm/i915: fix S4 suspend while switcheroo state is off
Quoted 8 lines · Imre Deak
If the device is suspended already through the switcheroo interface we shouldn't suspend it again. We have the corresponding check for S3 suspend already, add it for S4 freeze and poweroff too.
Note that there is still the problem that the resume path should also check for the switcheroo-off state and keep the device disabled or in case of S4 disable it. That is a separate issue, which is not addressed in this patchset.
That's about RESUME/RESTORE I take it.
But what about .thaw()? I think simply adding the same check to .thaw() would work out just fine since it's always called after .freeze() for THAW/RECOVER.
Quoted 47 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_drv.c +9
-0@@ -994,6 +994,9 @@ static int i915_pm_freeze(struct device *dev)return -ENODEV ; } +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }@@ -1003,6 +1006,9 @@ static int i915_pm_freeze_late(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);struct drm_i915_private *dev_priv = drm_dev->dev_private; +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return intel_suspend_complete (dev_priv); }@@ -1027,6 +1033,9 @@ static int i915_pm_poweroff(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 07/16] drm/i915: fix S4 suspend while switcheroo state is off
Quoted 10 lines · Ville Syrjälä
Quoted 8 lines · Imre Deak
If the device is suspended already through the switcheroo interface we shouldn't suspend it again. We have the corresponding check for S3 suspend already, add it for S4 freeze and poweroff too.
Note that there is still the problem that the resume path should also check for the switcheroo-off state and keep the device disabled or in case of S4 disable it. That is a separate issue, which is not addressed in this patchset.
Quoted 5 lines
That's about RESUME/RESTORE I take it.
But what about .thaw()? I think simply adding the same check to .thaw() would work out just fine since it's always called after .freeze() for THAW/RECOVER.
Yes, the check is missing from there too (actually by the end of the patchset THAW/RESUME/RESTORE are handled the same way). I didn't want to fix up that part in this patchset, since I thought avoiding RESTORE in case DRM_SWITCH_POWER_OFF is set is not enough during S4, we have to actually disable the device if it was enabled. But thinking about it again that seems to be not true, since before RESTORE FREEZE is called in the loader kernel, which leaves the device in a disabled state.
So I can put the check to .thaw too (.suspend by the end of the patchset), but it'd be easier to do it on top of this patchset if that's ok.
--Imre
Quoted 41 lines
Quoted 41 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_drv.c +9
-0@@ -994,6 +994,9 @@ static int i915_pm_freeze(struct device *dev)return -ENODEV ; } +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }@@ -1003,6 +1006,9 @@ static int i915_pm_freeze_late(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);struct drm_i915_private *dev_priv = drm_dev->dev_private; +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return intel_suspend_complete (dev_priv); }@@ -1027,6 +1033,9 @@ static int i915_pm_poweroff(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }
Quoted 8 lines
Quoted 7 lines
Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: fix S4 suspend while switcheroo state is off
Quoted 17 lines · Imre Deak
Quoted 10 lines · Ville Syrjälä
Quoted 8 lines · Imre Deak
If the device is suspended already through the switcheroo interface we shouldn't suspend it again. We have the corresponding check for S3 suspend already, add it for S4 freeze and poweroff too.
Note that there is still the problem that the resume path should also check for the switcheroo-off state and keep the device disabled or in case of S4 disable it. That is a separate issue, which is not addressed in this patchset.
Quoted 5 lines
That's about RESUME/RESTORE I take it.
But what about .thaw()? I think simply adding the same check to .thaw() would work out just fine since it's always called after .freeze() for THAW/RECOVER.
Quoted 7 lines
Yes, the check is missing from there too (actually by the end of the patchset THAW/RESUME/RESTORE are handled the same way). I didn't want to fix up that part in this patchset, since I thought avoiding RESTORE in case
DRM_SWITCH_POWER_OFFis set is not enough during S4, we have to actually disable the device if it was enabled. But thinking about it again that seems to be not true, since before RESTORE FREEZE is called in the loader kernel, which leaves the device in a disabled state.
I was thinking just about fixing THAW/RECOVER since those get executed from the same kernel as FREEZE/QUIESCE, but I guess you're correct that we can just handle RESUME/RESTORE the same way since SUSPEND/QUIESCE in the pre-resume kernel should have disabled the device anyway in case it was enabled, which means the state will match the switcheroo disabled state in the resumed kernel. And if switcheroo says the device should be enabled we enable it normally when resuming. So yeah, sounds like it should just work (tm).
Quoted 4 lines
So I can put the check to .thaw too (.suspend by the end of the patchset), but it'd be easier to do it on top of this patchset if that's ok.
Sure.
Quoted 53 lines
--Imre
Quoted 49 lines
Quoted 48 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_drv.c +9
-0@@ -994,6 +994,9 @@ static int i915_pm_freeze(struct device *dev)return -ENODEV ; } +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }@@ -1003,6 +1006,9 @@ static int i915_pm_freeze_late(struct device *dev)struct drm_device *drm_dev =pci_get_drvdata (pdev);struct drm_i915_private *dev_priv = drm_dev->dev_private; +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return intel_suspend_complete (dev_priv); }@@ -1027,6 +1033,9 @@ static int i915_pm_poweroff(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +return 0 ; +return i915_drm_freeze (drm_dev); }Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 8/16 drm/i915: remove unused restore_gtt_mappings optimization during suspend
In reply to Imre DeakThe logic to skip restoring GTT mappings was added to speed up suspend/resume, but not on old GENs where not restoring them caused problems. The check for old GENs is based on the existance of OpRegion, but this doesn't work since opregion is initialized only after the check. So we end up always restoring the mappings.
On my BYT - which has OpRegion - skipping restoring the mappings during suspend doesn't work, I get a GPU hang after resume. Also the logic of when to allow the optimization during S4 is reversed: we should allow it during S4 thaw but not during S4 restore, but atm we have it the other way around in the code.
Since correctness wins over optimal code and since the optimization wasn't used anyway I decided not to try to fix it at this point, but just remove it. This allows us to unify the S3 and S4 handlers in the following patches.
--- drivers/gpu/drm/i915/i915_drv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +4 -11
@@ -667,12 +667,11 @@ static int i915_drm_thaw_early(struct drm_device *dev)return ret; } -static int __i915_drm_thaw (struct drm_device *dev,bool restore_gtt_mappings) +static int __i915_drm_thaw (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (drm_core_check_feature (dev,DRIVER_MODESET ) && - restore_gtt_mappings) { +if (drm_core_check_feature (dev,DRIVER_MODESET )) {mutex_lock (&dev->struct_mutex);i915_gem_restore_gtt_mappings (dev);mutex_unlock (&dev->struct_mutex);
@@ -740,7 +739,7 @@ static int i915_drm_thaw(struct drm_device *dev)if (drm_core_check_feature (dev,DRIVER_MODESET ))i915_check_and_clear_faults (dev); -return __i915_drm_thaw (dev, true); +return __i915_drm_thaw (dev); }static int i915_resume_early (struct drm_device *dev)
@@ -767,15 +766,9 @@ static int i915_resume_early(struct drm_device *dev)static int i915_drm_resume (struct drm_device *dev) { -struct drm_i915_private *dev_priv = dev->dev_private;int ret; -/* -* Platforms with opregion should have sane BIOS, older ones (gen3 and -* earlier) need to restore the GTT mappings since the BIOS might clear -* all our scratch PTEs. -*/ - ret =__i915_drm_thaw (dev, !dev_priv->opregion.header); + ret =__i915_drm_thaw (dev);if (ret)return ret;
Signature · 1 line
1.8.4
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
Quoted 1 line · Imre Deak
Since correctness wins over optimal code and since the optimization
Optimal code is also correct ;-) s/optimal/just plain broken/ -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
Quoted 4 lines · Chris Wilson
Quoted 1 line · Imre Deak
Since correctness wins over optimal code and since the optimization
Optimal code is also correct ;-) s/optimal/just plain broken/
Yes, bad wording. To clarify, since the optimization is now always off anyway (and it's also broken), I would hope that we could remove it for now and concentrate on fixing the existing s/r issues. Once we find that things are stable enough we could add back this optimization.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
Quoted 10 lines · On Thu, 11 Sep 2014 14:59:35 +0300 Imre Deak <[email protected]> wrote:
Quoted 4 lines · Chris Wilson
Quoted 1 line · Imre Deak
Since correctness wins over optimal code and since the optimization
Optimal code is also correct ;-) s/optimal/just plain broken/
Yes, bad wording. To clarify, since the optimization is now always off anyway (and it's also broken), I would hope that we could remove it for now and concentrate on fixing the existing s/r issues. Once we find that things are stable enough we could add back this optimization.
Arg, I guess we didn't test after moving to the opregion test? Or maybe it was working when it landed for S3 and not for S4? Or broke sometime after it landed?
Anyway this is a really valuable optimization for resume time on some platforms, and really we shouldn't have other agents clobbering our GTT on resume, so I'd really like to fix/re-add it asap.
Jesse
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
Quoted 14 lines · Jesse Barnes
Quoted 10 lines · On Thu, 11 Sep 2014 14:59:35 +0300 Imre Deak <[email protected]> wrote:
Quoted 4 lines · Chris Wilson
Quoted 1 line · Imre Deak
Since correctness wins over optimal code and since the optimization
Optimal code is also correct ;-) s/optimal/just plain broken/
Yes, bad wording. To clarify, since the optimization is now always off anyway (and it's also broken), I would hope that we could remove it for now and concentrate on fixing the existing s/r issues. Once we find that things are stable enough we could add back this optimization.
Quoted 7 lines
Arg, I guess we didn't test after moving to the opregion test? Or maybe it was working when it landed for S3 and not for S4? Or broke sometime after it landed?
Anyway this is a really valuable optimization for resume time on some platforms, and really we shouldn't have other agents clobbering our GTT on resume, so I'd really like to fix/re-add it asap.
If/when we add this back I would suggest that we also add a sanity check that can be enabled with drm.debug which would verify the GTT mapping are what we expect. That way at least most developer would have it enabled and we'd catch problems earlier, and also bug reporters would be forced to enable it when we ask for dmesg w/ debugs.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
Quoted 26 lines · On Tue, 21 Oct 2014 16:50:12 +0300 Ville Syrjälä…
Quoted 16 lines · Jesse Barnes
Quoted 5 lines · On Thu, 11 Sep 2014 14:59:35 +0300 Imre Deak <[email protected]> wrote:
Quoted 4 lines · Chris Wilson
Quoted 2 lines · Imre Deak
Since correctness wins over optimal code and since the optimization
Quoted 7 lines
Quoted 1 line
Optimal code is also correct ;-) s/optimal/just plain broken/
Yes, bad wording. To clarify, since the optimization is now always off anyway (and it's also broken), I would hope that we could remove it for now and concentrate on fixing the existing s/r issues. Once we find that things are stable enough we could add back this optimization.
Quoted 8 lines
Arg, I guess we didn't test after moving to the opregion test? Or maybe it was working when it landed for S3 and not for S4? Or broke sometime after it landed?
Anyway this is a really valuable optimization for resume time on some platforms, and really we shouldn't have other agents clobbering our GTT on resume, so I'd really like to fix/re-add it asap.
Quoted 6 lines
If/when we add this back I would suggest that we also add a sanity check that can be enabled with drm.debug which would verify the GTT mapping are what we expect. That way at least most developer would have it enabled and we'd catch problems earlier, and also bug reporters would be forced to enable it when we ask for dmesg w/ debugs.
Yeah we had that awhile back iirc, but I think it got bikeshedded to death. I'd be happy if someone resurrected it; I'd give it an r-b without suggesting more sophisticated checksum algorithms. :)
http://lists.freedesktop.org/archives/intel-gfx/2012-September/020305.html
Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: remove unused restore_gtt_mappings optimization during suspend
In reply to Imre DeakQuoted 12 lines · Imre Deak
The logic to skip restoring GTT mappings was added to speed up suspend/resume, but not on old GENs where not restoring them caused problems. The check for old GENs is based on the existance of OpRegion, but this doesn't work since opregion is initialized only after the check. So we end up always restoring the mappings.
On my BYT - which has OpRegion - skipping restoring the mappings during suspend doesn't work, I get a GPU hang after resume. Also the logic of when to allow the optimization during S4 is reversed: we should allow it during S4 thaw but not during S4 restore, but atm we have it the other way around in the code.
Quoted 6 lines
Since correctness wins over optimal code and since the optimization wasn't used anyway I decided not to try to fix it at this point, but just remove it. This allows us to unify the S3 and S4 handlers in the following patches.
Signed-off-by Imre Deak <[email protected]>
Adding Jesse. Also he claimed that it actually helped back in
commit 1abd02e2dd7e0bd577000301fb2fd47780637387
Author: Jesse Barnes <[email protected]> Date: Fri Nov 2 11:14:02 2012 -0700
drm/i915: don't rewrite the GTT on resume v4
dunno where exactly this broke.
-Daniel
Quoted 56 lines
--- drivers/gpu/drm/i915/i915_drv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/gpu/drm/i915/i915_drv.c +4
-11@@ -667,12 +667,11 @@ static int i915_drm_thaw_early(struct drm_device *dev)return ret; } -static int __i915_drm_thaw (struct drm_device *dev,bool restore_gtt_mappings) +static int __i915_drm_thaw (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (drm_core_check_feature (dev,DRIVER_MODESET ) && - restore_gtt_mappings) { +if (drm_core_check_feature (dev,DRIVER_MODESET )) {mutex_lock (&dev->struct_mutex);i915_gem_restore_gtt_mappings (dev);mutex_unlock (&dev->struct_mutex);@@ -740,7 +739,7 @@ static int i915_drm_thaw(struct drm_device *dev)if (drm_core_check_feature (dev,DRIVER_MODESET ))i915_check_and_clear_faults (dev); -return __i915_drm_thaw (dev, true); +return __i915_drm_thaw (dev); }static int i915_resume_early (struct drm_device *dev)@@ -767,15 +766,9 @@ static int i915_resume_early(struct drm_device *dev)static int i915_drm_resume (struct drm_device *dev) { -struct drm_i915_private *dev_priv = dev->dev_private;int ret; -/* -* Platforms with opregion should have sane BIOS, older ones (gen3 and -* earlier) need to restore the GTT mappings since the BIOS might clear -* all our scratch PTEs. -*/ - ret =__i915_drm_thaw (dev, !dev_priv->opregion.header); + ret =__i915_drm_thaw (dev);if (ret)return ret;Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 9/16 drm/i915: check for GT faults during S3 resume and S4 restore too
In reply to Imre DeakChecking for GT faults is not specific in any way to S4 thaw, so do it also during S3 resume and S4 restore. This allows us to unify the handlers for these events in an upcoming patch.
--- drivers/gpu/drm/i915/i915_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -3
@@ -672,6 +672,8 @@ static int __i915_drm_thaw(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;if (drm_core_check_feature (dev,DRIVER_MODESET )) { +i915_check_and_clear_faults (dev); +mutex_lock (&dev->struct_mutex);i915_gem_restore_gtt_mappings (dev);mutex_unlock (&dev->struct_mutex);
@@ -736,9 +738,6 @@ static int __i915_drm_thaw(struct drm_device *dev)static int i915_drm_thaw (struct drm_device *dev) { -if (drm_core_check_feature (dev,DRIVER_MODESET )) -i915_check_and_clear_faults (dev); -return __i915_drm_thaw (dev); }
Signature · 1 line
1.8.4
Re: [PATCH 09/16] drm/i915: check for GT faults during S3 resume and S4 restore too
Quoted 3 lines · Imre Deak
Checking for GT faults is not specific in any way to S4 thaw, so do it also during S3 resume and S4 restore. This allows us to unify the handlers for these events in an upcoming patch.
So why not just move i915_check_and_clear_faults() to intel_uncore_early_santize()? That would seem to be the right BIOS scrubbing function that should also be doing this task. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 09/16] drm/i915: check for GT faults during S3 resume and S4 restore too
Quoted 8 lines · Chris Wilson
Quoted 3 lines · Imre Deak
Checking for GT faults is not specific in any way to S4 thaw, so do it also during S3 resume and S4 restore. This allows us to unify the handlers for these events in an upcoming patch.
So why not just move
i915_check_and_clear_faults()tointel_uncore_early_santize()? That would seem to be the right BIOS scrubbing function that should also be doing this task.
Ok, haven't consider moving the check, but it makes sense.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 9/16 drm/i915: check for GT faults in all resume handlers and driver load time
In reply to Imre DeakChecking for GT faults is not specific in any way to S4 thaw, so do it also during S3 resume, S4 restore and driver load time. This allows us to unify the Sx handlers in an upcoming patch.
v2:
- move the check to intel_uncore_early_sanitize(), so we check at driver load time too (Chris)
--- drivers/gpu/drm/i915/i915_drv.c | 3 --- drivers/gpu/drm/i915/intel_uncore.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -3
@@ -736,9 +736,6 @@ static int __i915_drm_thaw(struct drm_device *dev)static int i915_drm_thaw (struct drm_device *dev) { -if (drm_core_check_feature (dev,DRIVER_MODESET )) -i915_check_and_clear_faults (dev); -return __i915_drm_thaw (dev); }
drivers/gpu/drm/i915/intel_uncore.c +11 -2
@@ -363,7 +363,8 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)spin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } -void intel_uncore_early_sanitize (struct drm_device *dev,bool restore_forcewake) +static void __intel_uncore_early_sanitize (struct drm_device *dev, +bool restore_forcewake) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -389,6 +390,12 @@ void intel_uncore_early_sanitize(struct drm_device *dev, bool restore_forcewake)intel_uncore_forcewake_reset (dev, restore_forcewake); } +void intel_uncore_early_sanitize (struct drm_device *dev,bool restore_forcewake) +{ +__intel_uncore_early_sanitize (dev, restore_forcewake); +i915_check_and_clear_faults (dev); +} +void intel_uncore_sanitize (struct drm_device *dev) {/* BIOS often leaves RC6 enabled, but disable it for hw init */
@@ -833,7 +840,7 @@ void intel_uncore_init(struct drm_device *dev)setup_timer (&dev_priv->uncore.force_wake_timer, gen6_force_wake_timer, (unsigned long )dev_priv); -intel_uncore_early_sanitize (dev, false); +__intel_uncore_early_sanitize (dev, false);if (IS_VALLEYVIEW (dev)) { dev_priv->uncore.funcs.force_wake_get = __vlv_force_wake_get;
@@ -951,6 +958,8 @@ void intel_uncore_init(struct drm_device *dev) dev_priv->uncore.funcs.mmio_readq = gen4_read64;break ; } + +i915_check_and_clear_faults (dev); }void intel_uncore_fini (struct drm_device *dev)
Signature · 1 line
1.8.4
Re: [PATCH v2 09/16] drm/i915: check for GT faults in all resume handlers and driver load time
Quoted 9 lines · Imre Deak
Checking for GT faults is not specific in any way to S4 thaw, so do it also during S3 resume, S4 restore and driver load time. This allows us to unify the Sx handlers in an upcoming patch.
v2:
- move the check tointel_uncore_early_sanitize(), so we check at driver load time too (Chris)Signed-off-by Imre Deak <[email protected]>
I stared at early_sanitize and sanitize and decided that what you did here was correct,
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 10/16 drm/i915: enable output polling during S4 thaw
In reply to Imre DeakTo avoid processing hotplug events we disable connector polling for the duration of S3 suspend. We also disable it for S4 freeze, and keep it disabled after S4 thaw. This won't prevent though hotplug processing, since we re-enable interrupts anyway. There is also no need to prevent it at that time, since we reinitialize everything during thaw, so the device is in a consistent state. So to simplify things enable polling during thaw, which will allow us to handle S4 thaw the same way as S3 resume in an upcoming patch.
--- drivers/gpu/drm/i915/i915_drv.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +3 -8
@@ -733,6 +733,8 @@ static int __i915_drm_thaw(struct drm_device *dev)intel_opregion_notify_adapter (dev,PCI_D0 ); +drm_kms_helper_poll_enable (dev); +return 0 ; }
@@ -765,14 +767,7 @@ static int i915_resume_early(struct drm_device *dev)static int i915_drm_resume (struct drm_device *dev) { -int ret; - - ret =__i915_drm_thaw (dev); -if (ret) -return ret; - -drm_kms_helper_poll_enable (dev); -return 0 ; +return __i915_drm_thaw (dev); }static int i915_resume_legacy (struct drm_device *dev)
Signature · 1 line
1.8.4
PATCH 11/16 drm/i915: disable/re-enable PCI device around S4 freeze/thaw
In reply to Imre DeakWe already disable everything during S4 freeze, except the PCI device itself. There is no reason why we couldn't disable that too and doing so allows us to unify these handlers in the next patch with the corresponding S3 suspend/resume handlers.
--- drivers/gpu/drm/i915/i915_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -3
@@ -991,12 +991,11 @@ static int i915_pm_freeze_late(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct drm_i915_private *dev_priv = drm_dev->dev_private;if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; -return intel_suspend_complete (dev_priv); +return i915_drm_suspend_late (drm_dev); }static int i915_pm_thaw_early (struct device *dev)
@@ -1004,7 +1003,7 @@ static int i915_pm_thaw_early(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -return i915_drm_thaw_early (drm_dev); +return i915_resume_early (drm_dev); }static int i915_pm_thaw (struct device *dev)
Signature · 1 line
1.8.4
Re: [PATCH 11/16] drm/i915: disable/re-enable PCI device around S4 freeze/thaw
Quoted 4 lines · Imre Deak
We already disable everything during S4 freeze, except the PCI device itself. There is no reason why we couldn't disable that too and doing so allows us to unify these handlers in the next patch with the corresponding S3 suspend/resume handlers.
First I was a bit WTF because the PCI core doesn't seem to explicitly set the device back to D0 in .thaw() whereas it does for .restore()/.resume(). But then I realized pci_enable_device() does that anyway, so this looks fine.
To properly optimize .freeze()/.thaw() we should basically just quiesce the device but leave everything powered on. But such optimizations are for the future, and in the meantime sharing the same codepaths should mean we have the same bugs for both, instead of slightly different bugs for each.
Quoted 40 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.c +2
-3@@ -991,12 +991,11 @@ static int i915_pm_freeze_late(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct drm_i915_private *dev_priv = drm_dev->dev_private;if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; -return intel_suspend_complete (dev_priv); +return i915_drm_suspend_late (drm_dev); }static int i915_pm_thaw_early (struct device *dev)@@ -1004,7 +1003,7 @@ static int i915_pm_thaw_early(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -return i915_drm_thaw_early (drm_dev); +return i915_resume_early (drm_dev); }static int i915_pm_thaw (struct device *dev)Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 12/16 drm/i915: unify S3 and S4 suspend/resume handlers
In reply to Imre DeakThe S3 and S4 events are now handled the same way internally, there is no need to keep separate wrapper functions around them. Simply reuse the suspend/resume versions everywhere.
No functional change.
--- drivers/gpu/drm/i915/i915_drv.c | 98 +++++++---------------------------------- 1 file changed, 17 insertions(+), 81 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +17 -81
@@ -651,22 +651,6 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)return i915_drm_suspend_late (dev); } -static int i915_drm_thaw_early (struct drm_device *dev) -{ -struct drm_i915_private *dev_priv = dev->dev_private; -int ret; - - ret =intel_resume_prepare (dev_priv, false); -if (ret) -DRM_ERROR ("Resume prepare failed: %d,Continuing resume\n" , ret); - -intel_uncore_early_sanitize (dev, true); -intel_uncore_sanitize (dev); -intel_power_domains_init_hw (dev_priv); - -return ret; -} -static int __i915_drm_thaw (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -738,13 +722,11 @@ static int __i915_drm_thaw(struct drm_device *dev)return 0 ; } -static int i915_drm_thaw (struct drm_device *dev) -{ -return __i915_drm_thaw (dev); -} -static int i915_resume_early (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private; +int ret; +if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ;
@@ -762,7 +744,15 @@ static int i915_resume_early(struct drm_device *dev)pci_set_master (dev->pdev); -return i915_drm_thaw_early (dev); + ret =intel_resume_prepare (dev_priv, false); +if (ret) +DRM_ERROR ("Resume prepare failed: %d,Continuing resume\n" , ret); + +intel_uncore_early_sanitize (dev, true); +intel_uncore_sanitize (dev); +intel_power_domains_init_hw (dev_priv); + +return ret; }static int i915_drm_resume (struct drm_device *dev)
@@ -971,60 +961,6 @@ static int i915_pm_resume(struct device *dev)return i915_drm_resume (drm_dev); } -static int i915_pm_freeze (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct drm_device *drm_dev =pci_get_drvdata (pdev); - -if (!drm_dev || !drm_dev->dev_private) { -dev_err (dev,"DRM not initialized, aborting suspend.\n" ); -return -ENODEV ; - } - -if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) -return 0 ; - -return i915_drm_freeze (drm_dev); -} - -static int i915_pm_freeze_late (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct drm_device *drm_dev =pci_get_drvdata (pdev); - -if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) -return 0 ; - -return i915_drm_suspend_late (drm_dev); -} - -static int i915_pm_thaw_early (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct drm_device *drm_dev =pci_get_drvdata (pdev); - -return i915_resume_early (drm_dev); -} - -static int i915_pm_thaw (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct drm_device *drm_dev =pci_get_drvdata (pdev); - -return i915_drm_thaw (drm_dev); -} - -static int i915_pm_poweroff (struct device *dev) -{ -struct pci_dev *pdev =to_pci_dev (dev); -struct drm_device *drm_dev =pci_get_drvdata (pdev); - -if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) -return 0 ; - -return i915_drm_freeze (drm_dev); -} -static int hsw_suspend_complete (struct drm_i915_private *dev_priv) {hsw_enable_pc8 (dev_priv);
@@ -1584,11 +1520,11 @@ static const struct dev_pm_ops i915_pm_ops = { .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, - .freeze = i915_pm_freeze, - .freeze_late = i915_pm_freeze_late, - .thaw_early = i915_pm_thaw_early, - .thaw = i915_pm_thaw, - .poweroff = i915_pm_poweroff, + .freeze = i915_pm_suspend, + .freeze_late = i915_pm_suspend_late, + .thaw_early = i915_pm_resume_early, + .thaw = i915_pm_resume, + .poweroff = i915_pm_suspend, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, .runtime_suspend = intel_runtime_suspend,
Signature · 1 line
1.8.4
PATCH 13/16 drm/i915: sanitize suspend/resume helper function names
In reply to Imre DeakBy now the S4 freeze/thaw and S3 suspend/resume events are handled the same way, so we can rename the freeze/thaw internal helpers to suspend/resume accordingly to make clearer what the helpers do. Also rename i915_resume_early to i915_drm_resume_early aligning it with the rest of the helper names.
No functional change.
--- drivers/gpu/drm/i915/i915_drv.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +7 -12
@@ -532,7 +532,7 @@ static int intel_suspend_complete(struct drm_i915_private *dev_priv);static int intel_resume_prepare (struct drm_i915_private *dev_priv,bool rpm_resume); -static int i915_drm_freeze (struct drm_device *dev) +static int i915_drm_suspend (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;struct drm_crtc *crtc;
@@ -644,14 +644,14 @@ int i915_suspend(struct drm_device *dev, pm_message_t state)if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; - error =i915_drm_freeze (dev); + error =i915_drm_suspend (dev);if (error)return error;return i915_drm_suspend_late (dev); } -static int __i915_drm_thaw (struct drm_device *dev) +static int i915_drm_resume (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -722,7 +722,7 @@ static int __i915_drm_thaw(struct drm_device *dev)return 0 ; } -static int i915_resume_early (struct drm_device *dev) +static int i915_drm_resume_early (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;int ret;
@@ -755,16 +755,11 @@ static int i915_resume_early(struct drm_device *dev)return ret; } -static int i915_drm_resume (struct drm_device *dev) -{ -return __i915_drm_thaw (dev); -} -static int i915_resume_legacy (struct drm_device *dev) {int ret; - ret =i915_resume_early (dev); + ret =i915_drm_resume_early (dev);if (ret)return ret;
@@ -922,7 +917,7 @@ static int i915_pm_suspend(struct device *dev)if (drm_dev->switch_power_state ==DRM_SWITCH_POWER_OFF )return 0 ; -return i915_drm_freeze (drm_dev); +return i915_drm_suspend (drm_dev); }static int i915_pm_suspend_late (struct device *dev)
@@ -950,7 +945,7 @@ static int i915_pm_resume_early(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -return i915_resume_early (drm_dev); +return i915_drm_resume_early (drm_dev); }static int i915_pm_resume (struct device *dev)
Signature · 1 line
1.8.4
PATCH 14/16 drm/i915: add poweroff_late handler
In reply to Imre DeakThe suspend_late handler saves some registers and powers off the device, so it doesn't have a big overhead. Calling it at S4 poweroff_late time makes the power off handling identical to the S3 suspend and S4 freeze handling, so do this for consistency.
--- drivers/gpu/drm/i915/i915_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/i915_drv.c +1 -0
@@ -1520,6 +1520,7 @@ static const struct dev_pm_ops i915_pm_ops = { .thaw_early = i915_pm_resume_early, .thaw = i915_pm_resume, .poweroff = i915_pm_suspend, + .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, .runtime_suspend = intel_runtime_suspend,
Signature · 1 line
1.8.4
Re: [PATCH 14/16] drm/i915: add poweroff_late handler
Quoted 4 lines · Imre Deak
The
suspend_latehandler saves some registers and powers off the device, so it doesn't have a big overhead. Calling it at S4poweroff_latetime makes the power off handling identical to the S3 suspend and S4 freeze handling, so do this for consistency.
Heh. I was wondering where .poweroff_late() was when reading the earlier patches. I like consistency.
Quoted 25 lines
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/i915/i915_drv.c +1
-0@@ -1520,6 +1520,7 @@ static const struct dev_pm_ops i915_pm_ops = { .thaw_early = i915_pm_resume_early, .thaw = i915_pm_resume, .poweroff = i915_pm_suspend, + .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, .runtime_suspend = intel_runtime_suspend,Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 15/16 drm/i915: unify switcheroo and legacy suspend/resume handlers
In reply to Imre DeakBy now we handle switcheroo and legacy suspend/resume the same way, so no need to keep separate functions for them.
No functional change.
--- drivers/gpu/drm/i915/i915_dma.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.c | 11 +++-------- drivers/gpu/drm/i915/i915_drv.h | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -2
@@ -1274,12 +1274,12 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_ dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/* i915 resume handler doesn't set to D0 */ pci_set_power_state (dev->pdev,PCI_D0 ); -i915_resume (dev); +i915_resume_legacy (dev); dev->switch_power_state =DRM_SWITCH_POWER_ON ; }else {pr_err ("switched off\n" ); dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; -i915_suspend (dev, pmm); +i915_suspend_legacy (dev, pmm); dev->switch_power_state =DRM_SWITCH_POWER_OFF ; } }
drivers/gpu/drm/i915/i915_drv.c +3 -8
@@ -627,7 +627,7 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev)return 0 ; } -int i915_suspend (struct drm_device *dev,pm_message_t state) +int i915_suspend_legacy (struct drm_device *dev,pm_message_t state) {int error;
@@ -755,7 +755,7 @@ static int i915_drm_resume_early(struct drm_device *dev)return ret; } -static int i915_resume_legacy (struct drm_device *dev) +int i915_resume_legacy (struct drm_device *dev) {int ret;
@@ -766,11 +766,6 @@ static int i915_resume_legacy(struct drm_device *dev)return i915_drm_resume (dev); } -int i915_resume (struct drm_device *dev) -{ -return i915_resume_legacy (dev); -} -/** * i915_reset - reset chip after a hang * @dev: drm device to reset
@@ -1564,7 +1559,7 @@ static struct drm_driver driver = { .set_busid = drm_pci_set_busid,/* Used in place of i915_pm_ops for non-DRIVER_MODESET */ - .suspend = i915_suspend, + .suspend = i915_suspend_legacy, .resume = i915_resume_legacy, .device_is_agp = i915_driver_device_is_agp,
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -2205,8 +2205,8 @@ struct drm_i915_cmd_table {extern const struct drm_ioctl_desc i915_ioctls[];extern int i915_max_ioctl; -extern int i915_suspend (struct drm_device *dev,pm_message_t state); -extern int i915_resume (struct drm_device *dev); +extern int i915_suspend_legacy (struct drm_device *dev,pm_message_t state); +extern int i915_resume_legacy (struct drm_device *dev);extern int i915_master_create (struct drm_device *dev,struct drm_master *master);extern void i915_master_destroy (struct drm_device *dev,struct drm_master *master);
Signature · 1 line
1.8.4
PATCH 16/16 drm/i915: add comments on what stage a given PM handler is called
In reply to Imre DeakThis will hopefully make it easier to navigate the code without the need to consult the full PM documentation.
--- drivers/gpu/drm/i915/i915_drv.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +13 -0
@@ -1506,10 +1506,21 @@ static int intel_resume_prepare(struct drm_i915_private *dev_priv, }static const struct dev_pm_ops i915_pm_ops = { +/* S0ix, S3 event handlers */ .suspend = i915_pm_suspend, .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, + +/* +* S4 event handlers +* @freeze, @freeze_late : called before creating hibernation image +* @thaw, @thaw_early : called after creating hibernation image, +* before writing it +* @poweroff, @poweroff_late: called after writing hibernation image, +* before rebooting +* @restore, @restore_early : called after rebooting +*/ .freeze = i915_pm_suspend, .freeze_late = i915_pm_suspend_late, .thaw_early = i915_pm_resume_early,
@@ -1518,6 +1529,8 @@ static const struct dev_pm_ops i915_pm_ops = { .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, + +/* D0<->D3 (runtime PM) event handlers */ .runtime_suspend = intel_runtime_suspend, .runtime_resume = intel_runtime_resume, };
Signature · 1 line
1.8.4
PATCH v2 16/16 drm/i915: add comments on what stage a given PM handler is called
This will hopefully make it easier to navigate the code without the need to consult the full PM documentation.
v2:
- add a comment that the freeze handler is also called after rebooting
--- drivers/gpu/drm/i915/i915_drv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +16 -0
@@ -1504,10 +1504,24 @@ static int intel_resume_prepare(struct drm_i915_private *dev_priv, }static const struct dev_pm_ops i915_pm_ops = { +/* S0ix, S3 event handlers */ .suspend = i915_pm_suspend, .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, + +/* +* S4 event handlers +* @freeze, @freeze_late : called (1) before creating hibernation +* image and (2) after rebooting, before +* restoring the image +* @thaw, @thaw_early : called after creating hibernation image, +* before writing it +* @poweroff, @poweroff_late: called after writing hibernation image, +* before rebooting +* @restore, @restore_early : called after rebooting and restoring the +* image +*/ .freeze = i915_pm_suspend, .freeze_late = i915_pm_suspend_late, .thaw_early = i915_pm_resume_early,
@@ -1516,6 +1530,8 @@ static const struct dev_pm_ops i915_pm_ops = { .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, + +/* D0<->D3 (runtime PM) event handlers */ .runtime_suspend = intel_runtime_suspend, .runtime_resume = intel_runtime_resume, };
Signature · 1 line
1.8.4
Re: [PATCH 16/16] drm/i915: add comments on what stage a given PM handler is called
In reply to Imre DeakQuoted 13 lines · Imre Deak
This will hopefully make it easier to navigate the code without the need to consult the full PM documentation.
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/i915/i915_drv.c +0
-0
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1509
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.c +1
-0@@ -1506,10 +1506,21 @@ static int intel_resume_prepare(struct drm_i915_private *dev_priv, }static const struct dev_pm_ops i915_pm_ops = { +/* S0ix, S3 event handlers */
Well, S0ix can occur in due to runtime PM as well.
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1517
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +4
-0.suspend = i915_pm_suspend, .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, + +/* +* S4 event handlers +* @freeze, @freeze_late : called before creating hibernation image
That's FREEZE. Also called before restoring the hibenation image (QUIESCE).
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1519
Quoted 2 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0+* @thaw, @thaw_early : called after creating hibernation image, +* before writing it
That's THAW. Also called after failing the snapshot or restore (RECOVER).
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1522
Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.c +3
-0+* @poweroff, @poweroff_late: called after writing hibernation image, +* before rebooting +* @restore, @restore_early : called after rebooting
"after restoring the hibernation image" is what I'd say. That's RESTORE.
Quoted 20 lines
drivers/gpu/drm/i915/i915_drv.c +3
-0+*/ .freeze = i915_pm_suspend, .freeze_late = i915_pm_suspend_late, .thaw_early = i915_pm_resume_early,@@ -1518,6 +1529,8 @@ static const struct dev_pm_ops i915_pm_ops = { .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, + +/* D0<->D3 (runtime PM) event handlers */ .runtime_suspend = intel_runtime_suspend, .runtime_resume = intel_runtime_resume, };Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 16/16] drm/i915: add comments on what stage a given PM handler is called
Quoted 16 lines · Ville Syrjälä
Quoted 15 lines · Imre Deak
This will hopefully make it easier to navigate the code without the need to consult the full PM documentation.
Signed-off-by Imre Deak <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -1506,10 +1506,21 @@ static int intel_resume_prepare(struct drm_i915_private *dev_priv, }
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1509
Quoted 2 lines
drivers/gpu/drm/i915/i915_drv.c +1
-0static const struct dev_pm_ops i915_pm_ops = { +/* S0ix, S3 event handlers */ Well, S0ix can occur in due to runtime PM as well.
Ok, I'll add a note about this.
Quoted 11 lines
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1517
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.c +4
-0.suspend = i915_pm_suspend, .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early, .resume = i915_pm_resume, + +/* +* S4 event handlers +* @freeze, @freeze_late : called before creating hibernation image That's FREEZE. Also called before restoring the hibenation image (QUIESCE).
Yes, I noticed this and sent a v2 with that added.
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1519
Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0+* @thaw, @thaw_early : called after creating hibernation image, +* before writing it That's THAW. Also called after failing the snapshot or restore (RECOVER).
Ok, will add this.
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.c static int intel_resume_prepare(struct drm_i915_private *dev_priv, · line 1522
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.c +3
-0+* @poweroff, @poweroff_late: called after writing hibernation image, +* before rebooting +* @restore, @restore_early : called after rebooting "after restoring the hibernation image" is what I'd say. That's RESTORE.
This is also clarified in v2.
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/i915/i915_drv.c +3
-0+*/ .freeze = i915_pm_suspend, .freeze_late = i915_pm_suspend_late, .thaw_early = i915_pm_resume_early,@@ -1518,6 +1529,8 @@ static const struct dev_pm_ops i915_pm_ops = { .poweroff_late = i915_pm_suspend_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, + +/* D0<->D3 (runtime PM) event handlers */ .runtime_suspend = intel_runtime_suspend, .runtime_resume = intel_runtime_resume, };Signature · 1 line
1.8.4
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
Quoted 8 lines · Imre Deak
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
Hm, this might explain why we've seen random corruption on S4 on recent platforms.
https://bugzilla.kernel.org/show_bug.cgi?id=59321
Can you please ask for retesting from reporters?
Thanks, Daniel
Quoted 34 lines
I smoke tested this on BDW, HSW, VLV (BYT-M), IVB, GEN45.
Imre Deak (16):
drm/i915: vlv: fix gunit HW state corruption during S4 suspend drm/i915: remove dead code from legacy suspend handler drm/i915: factor outi915_drm_suspend_late
drm/i915: unify legacy S3 suspend and S4 freeze handlers drm/i915: propagate error from legacy resume handler drm/i915: vlv: fix switcheroo/legacy suspend/resume drm/i915: fix S4 suspend while switcheroo state is off drm/i915: remove unusedrestore_gtt_mappingsoptimization during
suspend
drm/i915: check for GT faults during S3 resume and S4 restore too drm/i915: enable output polling during S4 thaw drm/i915: disable/re-enable PCI device around S4 freeze/thaw drm/i915: unify S3 and S4 suspend/resume handlers drm/i915: sanitize suspend/resume helper function names drm/i915: addpoweroff_latehandler
drm/i915: unify switcheroo and legacy suspend/resume handlers drm/i915: add comments on what stage a given PM handler is calleddrivers/gpu/drm/i915/i915_dma.c | 4 +- drivers/gpu/drm/i915/i915_drv.c | 185 +++++++++++++++------------------------- drivers/gpu/drm/i915/i915_drv.h | 4 +- 3 files changed, 74 insertions(+), 119 deletions(-)Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · Imre Deak
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
Quoted 6 lines
Hm, this might explain why we've seen random corruption on S4 on recent platforms.
https://bugzilla.kernel.org/show_bug.cgi?id=59321
Can you please ask for retesting from reporters?
Ok, can do, I also forgot to add
https://bugs.freedesktop.org/show_bug.cgi?id=82842
which it fixes. I can't see immediately how platforms other than VLV would be fixed with these, but maybe I missed something.
--Imre
Quoted 36 lines
Thanks, Daniel
Quoted 34 lines
I smoke tested this on BDW, HSW, VLV (BYT-M), IVB, GEN45.
Imre Deak (16):
drm/i915: vlv: fix gunit HW state corruption during S4 suspend drm/i915: remove dead code from legacy suspend handler drm/i915: factor outi915_drm_suspend_late
drm/i915: unify legacy S3 suspend and S4 freeze handlers drm/i915: propagate error from legacy resume handler drm/i915: vlv: fix switcheroo/legacy suspend/resume drm/i915: fix S4 suspend while switcheroo state is off drm/i915: remove unusedrestore_gtt_mappingsoptimization during
suspend
drm/i915: check for GT faults during S3 resume and S4 restore too drm/i915: enable output polling during S4 thaw drm/i915: disable/re-enable PCI device around S4 freeze/thaw drm/i915: unify S3 and S4 suspend/resume handlers drm/i915: sanitize suspend/resume helper function names drm/i915: addpoweroff_latehandler
drm/i915: unify switcheroo and legacy suspend/resume handlers drm/i915: add comments on what stage a given PM handler is calleddrivers/gpu/drm/i915/i915_dma.c | 4 +- drivers/gpu/drm/i915/i915_drv.c | 185 +++++++++++++++------------------------- drivers/gpu/drm/i915/i915_drv.h | 4 +- 3 files changed, 74 insertions(+), 119 deletions(-)Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 16 lines · Imre Deak
Quoted 15 lines · Daniel Vetter
Quoted 8 lines · Imre Deak
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
Hm, this might explain why we've seen random corruption on S4 on recent platforms.
Quoted 8 lines
Quoted 1 line
Can you please ask for retesting from reporters?
Ok, can do, I also forgot to add
https://bugs.freedesktop.org/show_bug.cgi?id=82842
which it fixes. I can't see immediately how platforms other than VLV would be fixed with these, but maybe I missed something.
drm/i915: disable/re-enable PCI device around S4 freeze/thaw
looks rather generic and not vlv specific, and could very well fix the kernel bz I've pasted. Or am I horribly blind?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Imre Deak
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · Imre Deak
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
Quoted 6 lines
Hm, this might explain why we've seen random corruption on S4 on recent platforms.
https://bugzilla.kernel.org/show_bug.cgi?id=59321
Can you please ask for retesting from reporters?
Ok, can do, I also forgot to add
Quoted 7 lines
Quoted 2 lines
which it fixes. I can't see immediately how platforms other than VLV would be fixed with these, but maybe I missed something.
drm/i915: disable/re-enable PCI device around S4 freeze/thaw
looks rather generic and not vlv specific, and could very well fix the kernel bz I've pasted. Or am I horribly blind?
Yea it's generic, so possibly fixes something. Although by the time we disable the PCI device in freeze everything should be idle, so if simply disabling/re-enabling makes a difference then we failed to idle something. Or we depend on a HW reset (implicit in the disable/re-enable) before reinitializing things in thaw. Anyway we can clarify this more once we get feedback from the retesting.
--Imre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 21 lines · Imre Deak
The first part of the patchset (1-6) fixes an S4 bug on VLV introduced recently. The rest unifies the various S3/S4 handlers, which are in practice the same. The only real difference - besides some unused code - is that during S3 suspend we disable the PCI device whereas across an S4 freeze/thaw we keep it enabled. Given that we disable everything else anyway, we can just as well disable the PCI device there too. Doing so allows us to handle S3 suspend/resume and S4 freeze/thaw/restore/ power-off the same way, simplifying/clarifying things quite a bit.
I smoke tested this on BDW, HSW, VLV (BYT-M), IVB, GEN45.
Imre Deak (16):
drm/i915: vlv: fix gunit HW state corruption during S4 suspend drm/i915: remove dead code from legacy suspend handler drm/i915: factor outi915_drm_suspend_late
drm/i915: unify legacy S3 suspend and S4 freeze handlers drm/i915: propagate error from legacy resume handler drm/i915: vlv: fix switcheroo/legacy suspend/resume drm/i915: fix S4 suspend while switcheroo state is off drm/i915: remove unusedrestore_gtt_mappingsoptimization during
suspend
Quoted 8 lines
drm/i915: check for GT faults during S3 resume and S4 restore too drm/i915: enable output polling during S4 thaw drm/i915: disable/re-enable PCI device around S4 freeze/thaw drm/i915: unify S3 and S4 suspend/resume handlers drm/i915: sanitize suspend/resume helper function names drm/i915: add
poweroff_latehandler
drm/i915: unify switcheroo and legacy suspend/resume handlers drm/i915: add comments on what stage a given PM handler is called
It all looks pretty decent to me. You can slap
onto everything except 09/16. I was a bit lazy and didn't look at that one since Chris has already checked it.
Quoted 13 lines
drivers/gpu/drm/i915/i915_dma.c | 4 +- drivers/gpu/drm/i915/i915_drv.c | 185 +++++++++++++++------------------------- drivers/gpu/drm/i915/i915_drv.h | 4 +- 3 files changed, 74 insertions(+), 119 deletions(-)Signature · 6 lines
1.8.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC