* [PATCH] drm/nouveau: Drop superfluous DRM_SWITCH_POWER_DYNAMIC_OFF checks
@ 2016-11-08 11:57 Lukas Wunner
[not found] ` <0136d21975f52582f9cfe3ea313c3173c657c286.1478605864.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Lukas Wunner @ 2016-11-08 11:57 UTC (permalink / raw)
To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
nouveau's ->suspend and ->resume callbacks are currently skipped if the
device's status is either DRM_SWITCH_POWER_OFF (powered off by
vga_switcheroo manual power control) or DRM_SWITCH_POWER_DYNAMIC_OFF
(runtime suspended).
In the former case this makes sense since the device is powered off
behind the PM core's back: It will try to execute the ->suspend and
->resume callbacks upon system sleep, not knowing that the device is
inaccessible. Therefore the callbacks have to become no-ops.
However the latter case doesn't make any sense because the PM core
never calls the ->suspend and ->resume callbacks of runtime suspended
devices: Such devices are either runtime resumed before going to system
sleep (see call to pm_runtime_resume() in drivers/pci/pci-driver:
pci_pm_suspend()) or they are left runtime suspended over the entire
system suspend/resume process (search for "direct_complete" in
drivers/base/power/main.c).
Consequently the DRM_SWITCH_POWER_DYNAMIC_OFF checks are superfluous.
Drop them.
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9876e6f..d91d092 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -666,8 +666,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
struct drm_device *drm_dev = pci_get_drvdata(pdev);
int ret;
- if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
- drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
+ if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
ret = nouveau_do_suspend(drm_dev, false);
@@ -688,8 +687,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
struct drm_device *drm_dev = pci_get_drvdata(pdev);
int ret;
- if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
- drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
+ if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
pci_set_power_state(pdev, PCI_D0);
--
2.10.1
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <0136d21975f52582f9cfe3ea313c3173c657c286.1478605864.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH] drm/nouveau: Drop superfluous DRM_SWITCH_POWER_DYNAMIC_OFF checks [not found] ` <0136d21975f52582f9cfe3ea313c3173c657c286.1478605864.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> @ 2016-11-08 20:29 ` Peter Wu 2016-12-14 19:00 ` Lukas Wunner 0 siblings, 1 reply; 4+ messages in thread From: Peter Wu @ 2016-11-08 20:29 UTC (permalink / raw) To: Lukas Wunner; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Ben Skeggs On Tue, Nov 08, 2016 at 12:57:00PM +0100, Lukas Wunner wrote: > nouveau's ->suspend and ->resume callbacks are currently skipped if the > device's status is either DRM_SWITCH_POWER_OFF (powered off by > vga_switcheroo manual power control) or DRM_SWITCH_POWER_DYNAMIC_OFF > (runtime suspended). > > In the former case this makes sense since the device is powered off > behind the PM core's back: It will try to execute the ->suspend and > ->resume callbacks upon system sleep, not knowing that the device is > inaccessible. Therefore the callbacks have to become no-ops. > > However the latter case doesn't make any sense because the PM core > never calls the ->suspend and ->resume callbacks of runtime suspended > devices: Such devices are either runtime resumed before going to system > sleep (see call to pm_runtime_resume() in drivers/pci/pci-driver: > pci_pm_suspend()) or they are left runtime suspended over the entire > system suspend/resume process (search for "direct_complete" in > drivers/base/power/main.c). > > Consequently the DRM_SWITCH_POWER_DYNAMIC_OFF checks are superfluous. > Drop them. > > Signed-off-by: Lukas Wunner <lukas@wunner.de> It is better to rely on the official documentation rather than the implementation. Luckily, Documentation/power/pci.txt supports the claim: 2.4.1. System Suspend When the system is going into a sleep state in which the contents of memory will be preserved, such as one of the ACPI sleep states S1-S3, the phases are: prepare, suspend, suspend_noirq. [..] The pci_pm_prepare() routine first puts the device into the "fully functional" state with the help of pm_runtime_resume(). [..] So indeed we can be sure that the device is runtime-resumed before suspend. System resume is not documented explicitly, but it seems reasonable that the device is not runtime-suspended between system suspend and resume. Reviewed-by: Peter Wu <peter@lekensteyn.nl> > --- > drivers/gpu/drm/nouveau/nouveau_drm.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c > index 9876e6f..d91d092 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c > @@ -666,8 +666,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > struct drm_device *drm_dev = pci_get_drvdata(pdev); > int ret; > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > return 0; > > ret = nouveau_do_suspend(drm_dev, false); > @@ -688,8 +687,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > struct drm_device *drm_dev = pci_get_drvdata(pdev); > int ret; > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > return 0; > > pci_set_power_state(pdev, PCI_D0); > -- > 2.10.1 _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/nouveau: Drop superfluous DRM_SWITCH_POWER_DYNAMIC_OFF checks 2016-11-08 20:29 ` Peter Wu @ 2016-12-14 19:00 ` Lukas Wunner [not found] ` <20161214190016.GA11391-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Lukas Wunner @ 2016-12-14 19:00 UTC (permalink / raw) To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Hi Ben, On Tue, Nov 08, 2016 at 09:29:38PM +0100, Peter Wu wrote: > On Tue, Nov 08, 2016 at 12:57:00PM +0100, Lukas Wunner wrote: > > nouveau's ->suspend and ->resume callbacks are currently skipped if the > > device's status is either DRM_SWITCH_POWER_OFF (powered off by > > vga_switcheroo manual power control) or DRM_SWITCH_POWER_DYNAMIC_OFF > > (runtime suspended). > > > > In the former case this makes sense since the device is powered off > > behind the PM core's back: It will try to execute the ->suspend and > > ->resume callbacks upon system sleep, not knowing that the device is > > inaccessible. Therefore the callbacks have to become no-ops. > > > > However the latter case doesn't make any sense because the PM core > > never calls the ->suspend and ->resume callbacks of runtime suspended > > devices: Such devices are either runtime resumed before going to system > > sleep (see call to pm_runtime_resume() in drivers/pci/pci-driver: > > pci_pm_suspend()) or they are left runtime suspended over the entire > > system suspend/resume process (search for "direct_complete" in > > drivers/base/power/main.c). > > > > Consequently the DRM_SWITCH_POWER_DYNAMIC_OFF checks are superfluous. > > Drop them. > > > > Signed-off-by: Lukas Wunner <lukas@wunner.de> Just a gentle ping: This patch was posted a month ago and I'm not seeing it in your tree. Do you have objections? Should I repost with Peter's Reviewed-by? Thanks, Lukas > > It is better to rely on the official documentation rather than the > implementation. Luckily, Documentation/power/pci.txt supports the claim: > > 2.4.1. System Suspend > > When the system is going into a sleep state in which the contents of memory will > be preserved, such as one of the ACPI sleep states S1-S3, the phases are: > > prepare, suspend, suspend_noirq. > [..] > The pci_pm_prepare() routine first puts the device into the "fully functional" > state with the help of pm_runtime_resume(). [..] > > So indeed we can be sure that the device is runtime-resumed before > suspend. System resume is not documented explicitly, but it seems > reasonable that the device is not runtime-suspended between system > suspend and resume. > > Reviewed-by: Peter Wu <peter@lekensteyn.nl> > > > --- > > drivers/gpu/drm/nouveau/nouveau_drm.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c > > index 9876e6f..d91d092 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c > > @@ -666,8 +666,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > > struct drm_device *drm_dev = pci_get_drvdata(pdev); > > int ret; > > > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > > return 0; > > > > ret = nouveau_do_suspend(drm_dev, false); > > @@ -688,8 +687,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > > struct drm_device *drm_dev = pci_get_drvdata(pdev); > > int ret; > > > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > > return 0; > > > > pci_set_power_state(pdev, PCI_D0); > > -- > > 2.10.1 _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20161214190016.GA11391-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH] drm/nouveau: Drop superfluous DRM_SWITCH_POWER_DYNAMIC_OFF checks [not found] ` <20161214190016.GA11391-JFq808J9C/izQB+pC5nmwQ@public.gmane.org> @ 2016-12-18 17:01 ` Lukas Wunner 0 siblings, 0 replies; 4+ messages in thread From: Lukas Wunner @ 2016-12-18 17:01 UTC (permalink / raw) To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Hi Ben, On Wed, Dec 14, 2016 at 08:00:16PM +0100, Lukas Wunner wrote: > On Tue, Nov 08, 2016 at 09:29:38PM +0100, Peter Wu wrote: > > On Tue, Nov 08, 2016 at 12:57:00PM +0100, Lukas Wunner wrote: > > > nouveau's ->suspend and ->resume callbacks are currently skipped if the > > > device's status is either DRM_SWITCH_POWER_OFF (powered off by > > > vga_switcheroo manual power control) or DRM_SWITCH_POWER_DYNAMIC_OFF > > > (runtime suspended). > > > > > > In the former case this makes sense since the device is powered off > > > behind the PM core's back: It will try to execute the ->suspend and > > > ->resume callbacks upon system sleep, not knowing that the device is > > > inaccessible. Therefore the callbacks have to become no-ops. > > > > > > However the latter case doesn't make any sense because the PM core > > > never calls the ->suspend and ->resume callbacks of runtime suspended > > > devices: Such devices are either runtime resumed before going to system > > > sleep (see call to pm_runtime_resume() in drivers/pci/pci-driver: > > > pci_pm_suspend()) or they are left runtime suspended over the entire > > > system suspend/resume process (search for "direct_complete" in > > > drivers/base/power/main.c). > > > > > > Consequently the DRM_SWITCH_POWER_DYNAMIC_OFF checks are superfluous. > > > Drop them. > > > > > > Signed-off-by: Lukas Wunner <lukas@wunner.de> > > Just a gentle ping: This patch was posted a month ago and I'm not > seeing it in your tree. Do you have objections? Should I repost > with Peter's Reviewed-by? Forgot to mention: The rationale of this commit is that Alex Deucher added the same superfluous code to radeon and amdgpu with commits 5e0b1617fc38 and f46cf3735f4c. When asked he specifically pointed to nouveau doing the same. The code was subsequently removed again from radeon and amdgpu with commits f2aba352a954 and e313de7e8997. By removing the superfluous code from nouveau I would like to prevent it from being cargo-culted to further drivers. If you'd like me to resend with this additional explanation please shout. Thanks, Lukas > > > > It is better to rely on the official documentation rather than the > > implementation. Luckily, Documentation/power/pci.txt supports the claim: > > > > 2.4.1. System Suspend > > > > When the system is going into a sleep state in which the contents of memory will > > be preserved, such as one of the ACPI sleep states S1-S3, the phases are: > > > > prepare, suspend, suspend_noirq. > > [..] > > The pci_pm_prepare() routine first puts the device into the "fully functional" > > state with the help of pm_runtime_resume(). [..] > > > > So indeed we can be sure that the device is runtime-resumed before > > suspend. System resume is not documented explicitly, but it seems > > reasonable that the device is not runtime-suspended between system > > suspend and resume. > > > > Reviewed-by: Peter Wu <peter@lekensteyn.nl> > > > > > --- > > > drivers/gpu/drm/nouveau/nouveau_drm.c | 6 ++---- > > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c > > > index 9876e6f..d91d092 100644 > > > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c > > > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c > > > @@ -666,8 +666,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > > > struct drm_device *drm_dev = pci_get_drvdata(pdev); > > > int ret; > > > > > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > > > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > > > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > > > return 0; > > > > > > ret = nouveau_do_suspend(drm_dev, false); > > > @@ -688,8 +687,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, > > > struct drm_device *drm_dev = pci_get_drvdata(pdev); > > > int ret; > > > > > > - if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF || > > > - drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) > > > + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) > > > return 0; > > > > > > pci_set_power_state(pdev, PCI_D0); > > > -- > > > 2.10.1 _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-18 17:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-08 11:57 [PATCH] drm/nouveau: Drop superfluous DRM_SWITCH_POWER_DYNAMIC_OFF checks Lukas Wunner
[not found] ` <0136d21975f52582f9cfe3ea313c3173c657c286.1478605864.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-11-08 20:29 ` Peter Wu
2016-12-14 19:00 ` Lukas Wunner
[not found] ` <20161214190016.GA11391-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-12-18 17:01 ` Lukas Wunner
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.