dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: fail runtime pm properly.
@ 2014-03-26  4:09 Dave Airlie
  2014-03-26 13:10 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Airlie @ 2014-03-26  4:09 UTC (permalink / raw)
  To: dri-devel

From: Dave Airlie <airlied@redhat.com>

If we were on a non-optimus device, we'd return -EINVAL, this would
lead to the over engineered runtime pm system to go into an error
state, subsequent get_sync's would fail, so we'd never be able
to open the device again.

(like really get_sync shouldn't fail if the device isn't powered
down).

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 89c484d..4ee702a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -866,13 +866,16 @@ static int nouveau_pmops_runtime_suspend(struct device *dev)
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
 	int ret;
 
-	if (nouveau_runtime_pm == 0)
-		return -EINVAL;
+	if (nouveau_runtime_pm == 0) {
+		pm_runtime_forbid(dev);
+		return -EBUSY;
+	}
 
 	/* are we optimus enabled? */
 	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
 		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
-		return -EINVAL;
+		pm_runtime_forbid(dev);
+		return -EBUSY;
 	}
 
 	nv_debug_level(SILENT);
@@ -923,12 +926,15 @@ static int nouveau_pmops_runtime_idle(struct device *dev)
 	struct nouveau_drm *drm = nouveau_drm(drm_dev);
 	struct drm_crtc *crtc;
 
-	if (nouveau_runtime_pm == 0)
+	if (nouveau_runtime_pm == 0) {
+		pm_runtime_forbid(dev);
 		return -EBUSY;
+	}
 
 	/* are we optimus enabled? */
 	if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
 		DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
+		pm_runtime_forbid(dev);
 		return -EBUSY;
 	}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/nouveau: fail runtime pm properly.
  2014-03-26  4:09 [PATCH] drm/nouveau: fail runtime pm properly Dave Airlie
@ 2014-03-26 13:10 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2014-03-26 13:10 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Maling list - DRI developers

On Wed, Mar 26, 2014 at 12:09 AM, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> If we were on a non-optimus device, we'd return -EINVAL, this would
> lead to the over engineered runtime pm system to go into an error
> state, subsequent get_sync's would fail, so we'd never be able
> to open the device again.
>
> (like really get_sync shouldn't fail if the device isn't powered
> down).

Any chance you'd want to spin similar patches for radeon?

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 89c484d..4ee702a 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -866,13 +866,16 @@ static int nouveau_pmops_runtime_suspend(struct device *dev)
>         struct drm_device *drm_dev = pci_get_drvdata(pdev);
>         int ret;
>
> -       if (nouveau_runtime_pm == 0)
> -               return -EINVAL;
> +       if (nouveau_runtime_pm == 0) {
> +               pm_runtime_forbid(dev);
> +               return -EBUSY;
> +       }
>
>         /* are we optimus enabled? */
>         if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
>                 DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
> -               return -EINVAL;
> +               pm_runtime_forbid(dev);
> +               return -EBUSY;
>         }
>
>         nv_debug_level(SILENT);
> @@ -923,12 +926,15 @@ static int nouveau_pmops_runtime_idle(struct device *dev)
>         struct nouveau_drm *drm = nouveau_drm(drm_dev);
>         struct drm_crtc *crtc;
>
> -       if (nouveau_runtime_pm == 0)
> +       if (nouveau_runtime_pm == 0) {
> +               pm_runtime_forbid(dev);
>                 return -EBUSY;
> +       }
>
>         /* are we optimus enabled? */
>         if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) {
>                 DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
> +               pm_runtime_forbid(dev);
>                 return -EBUSY;
>         }
>
> --
> 1.8.3.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-26 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-26  4:09 [PATCH] drm/nouveau: fail runtime pm properly Dave Airlie
2014-03-26 13:10 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox