AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close
@ 2016-08-31 22:08 Alex Deucher
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Close was not handled correctly.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index f1b9e0f..45f98b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -600,6 +600,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 
 	kfree(fpriv);
 	file_priv->driver_priv = NULL;
+
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
 }
 
 /**
@@ -614,6 +617,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 void amdgpu_driver_preclose_kms(struct drm_device *dev,
 				struct drm_file *file_priv)
 {
+	pm_runtime_get_sync(dev->dev);
 }
 
 /*
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 02/10] drm/amdgpu: handle runtime pm correctly in amdgpu_driver_open_kms
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-08-31 22:08   ` Alex Deucher
       [not found]     ` <1472681336-30106-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-31 22:08   ` [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon Alex Deucher
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Need to fix the error pathes.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 45f98b4..c2c7fb1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -542,12 +542,16 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 		return r;
 
 	fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
-	if (unlikely(!fpriv))
-		return -ENOMEM;
+	if (unlikely(!fpriv)) {
+		r = -ENOMEM;
+		goto out_suspend;
+	}
 
 	r = amdgpu_vm_init(adev, &fpriv->vm);
-	if (r)
-		goto error_free;
+	if (r) {
+		kfree(fpriv);
+		goto out_suspend;
+	}
 
 	mutex_init(&fpriv->bo_list_lock);
 	idr_init(&fpriv->bo_list_handles);
@@ -556,12 +560,9 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 
 	file_priv->driver_priv = fpriv;
 
+out_suspend:
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
-	return 0;
-
-error_free:
-	kfree(fpriv);
 
 	return r;
 }
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-31 22:08   ` [PATCH 02/10] drm/amdgpu: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
       [not found]     ` <1472681336-30106-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-31 22:08   ` [PATCH 04/10] drm/amdgpu: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
                     ` (7 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Ported from nouveau.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 9191467..eaa5dcc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/fb.h>
+#include <linux/pm_runtime.h>
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
@@ -48,8 +49,32 @@ struct amdgpu_fbdev {
 	struct amdgpu_device *adev;
 };
 
+static int
+amdgpufb_open(struct fb_info *info, int user)
+{
+	struct amdgpu_fbdev *rfbdev = info->par;
+	struct amdgpu_device *adev = rfbdev->adev;
+	int ret = pm_runtime_get_sync(adev->ddev->dev);
+	if (ret < 0 && ret != -EACCES)
+		return ret;
+	return 0;
+}
+
+static int
+amdgpufb_release(struct fb_info *info, int user)
+{
+	struct amdgpu_fbdev *rfbdev = info->par;
+	struct amdgpu_device *adev = rfbdev->adev;
+
+	pm_runtime_mark_last_busy(adev->ddev->dev);
+	pm_runtime_put_autosuspend(adev->ddev->dev);
+	return 0;
+}
+
 static struct fb_ops amdgpufb_ops = {
 	.owner = THIS_MODULE,
+	.fb_open = amdgpufb_open,
+	.fb_release = amdgpufb_release,
 	.fb_check_var = drm_fb_helper_check_var,
 	.fb_set_par = drm_fb_helper_set_par,
 	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 04/10] drm/amdgpu: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-31 22:08   ` [PATCH 02/10] drm/amdgpu: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
  2016-08-31 22:08   ` [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
       [not found]     ` <1472681336-30106-4-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-31 22:08   ` [PATCH 05/10] drm/amdgpu: set runtime pm state to active on resume Alex Deucher
                     ` (6 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Missed this case previously. No need to do anything if the
device is already off.  runtime pm will handle it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f96334..e6b34dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1842,7 +1842,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon,
 
 	adev = dev->dev_private;
 
-	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
 		return 0;
 
 	drm_kms_helper_poll_disable(dev);
@@ -1926,7 +1927,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon,
 	struct drm_crtc *crtc;
 	int r;
 
-	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
 		return 0;
 
 	if (fbcon) {
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 05/10] drm/amdgpu: set runtime pm state to active on resume
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 04/10] drm/amdgpu: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-08-31 22:08   ` [PATCH 06/10] drm/radeon: handle runtime pm in drm pre/post close Alex Deucher
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

The sbios always powers up the dGPU on resume.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 716adb5..3426ae2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -495,6 +495,14 @@ static int amdgpu_pmops_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
+
+	/* GPU comes up enabled by the bios on resume */
+	if (amdgpu_device_is_px(drm_dev)) {
+		pm_runtime_disable(dev);
+		pm_runtime_set_active(dev);
+		pm_runtime_enable(dev);
+	}
+
 	return amdgpu_device_resume(drm_dev, true, true, false);
 }
 
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 06/10] drm/radeon: handle runtime pm in drm pre/post close
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 05/10] drm/amdgpu: set runtime pm state to active on resume Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-08-31 22:08   ` [PATCH 07/10] drm/radeon: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Close was not handled correctly.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_kms.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 835563c..0252527 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -717,6 +717,8 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 		kfree(fpriv);
 		file_priv->driver_priv = NULL;
 	}
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
 }
 
 /**
@@ -733,6 +735,8 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
 {
 	struct radeon_device *rdev = dev->dev_private;
 
+	pm_runtime_get_sync(dev->dev);
+
 	mutex_lock(&rdev->gem.mutex);
 	if (rdev->hyperz_filp == file_priv)
 		rdev->hyperz_filp = NULL;
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 07/10] drm/radeon: handle runtime pm correctly in amdgpu_driver_open_kms
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (4 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 06/10] drm/radeon: handle runtime pm in drm pre/post close Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-08-31 22:08   ` [PATCH 08/10] drm/radeon: handle runtime pm in fbcon Alex Deucher
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Need to fix the error paths.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_kms.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 0252527..4388dde 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -641,11 +641,11 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 	if (rdev->family >= CHIP_CAYMAN) {
 		struct radeon_fpriv *fpriv;
 		struct radeon_vm *vm;
-		int r;
 
 		fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
 		if (unlikely(!fpriv)) {
-			return -ENOMEM;
+			r = -ENOMEM;
+			goto out_suspend;
 		}
 
 		if (rdev->accel_working) {
@@ -653,14 +653,14 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 			r = radeon_vm_init(rdev, vm);
 			if (r) {
 				kfree(fpriv);
-				return r;
+				goto out_suspend;
 			}
 
 			r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
 			if (r) {
 				radeon_vm_fini(rdev, vm);
 				kfree(fpriv);
-				return r;
+				goto out_suspend;
 			}
 
 			/* map the ib pool buffer read only into
@@ -674,15 +674,16 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 			if (r) {
 				radeon_vm_fini(rdev, vm);
 				kfree(fpriv);
-				return r;
+				goto out_suspend;
 			}
 		}
 		file_priv->driver_priv = fpriv;
 	}
 
+out_suspend:
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
-	return 0;
+	return r;
 }
 
 /**
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 08/10] drm/radeon: handle runtime pm in fbcon
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (5 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 07/10] drm/radeon: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-08-31 22:08   ` [PATCH 09/10] drm/radeon: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Ported from nouveau.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_fb.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 0e3143a..1ae32c9 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/fb.h>
+#include <linux/pm_runtime.h>
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
@@ -47,8 +48,32 @@ struct radeon_fbdev {
 	struct radeon_device *rdev;
 };
 
+static int
+radeonfb_open(struct fb_info *info, int user)
+{
+	struct radeon_fbdev *rfbdev = info->par;
+	struct radeon_device *rdev = rfbdev->rdev;
+	int ret = pm_runtime_get_sync(rdev->ddev->dev);
+	if (ret < 0 && ret != -EACCES)
+		return ret;
+	return 0;
+}
+
+static int
+radeonfb_release(struct fb_info *info, int user)
+{
+	struct radeon_fbdev *rfbdev = info->par;
+	struct radeon_device *rdev = rfbdev->rdev;
+
+	pm_runtime_mark_last_busy(rdev->ddev->dev);
+	pm_runtime_put_autosuspend(rdev->ddev->dev);
+	return 0;
+}
+
 static struct fb_ops radeonfb_ops = {
 	.owner = THIS_MODULE,
+	.fb_open = radeonfb_open,
+	.fb_release = radeonfb_release,
 	.fb_check_var = drm_fb_helper_check_var,
 	.fb_set_par = drm_fb_helper_set_par,
 	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 09/10] drm/radeon: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (6 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 08/10] drm/radeon: handle runtime pm in fbcon Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-08-31 22:08   ` [PATCH 10/10] drm/radeon: set runtime pm state to active on resume Alex Deucher
  2016-09-01  1:03   ` [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close Michel Dänzer
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Missed this case previously. No need to do anything if the
device is already off.  runtime pm will handle it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 6b0d26f..8425b12 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1594,7 +1594,8 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
 
 	rdev = dev->dev_private;
 
-	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
 		return 0;
 
 	drm_kms_helper_poll_disable(dev);
@@ -1689,7 +1690,8 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
 	struct drm_crtc *crtc;
 	int r;
 
-	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
 		return 0;
 
 	if (fbcon) {
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* [PATCH 10/10] drm/radeon: set runtime pm state to active on resume
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (7 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 09/10] drm/radeon: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
@ 2016-08-31 22:08   ` Alex Deucher
  2016-09-01  1:03   ` [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close Michel Dänzer
  9 siblings, 0 replies; 19+ messages in thread
From: Alex Deucher @ 2016-08-31 22:08 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

The sbios always powers up the dGPU on resume.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/radeon_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 081e95e..5fdd48c 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -386,6 +386,14 @@ static int radeon_pmops_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
+
+	/* GPU comes up enabled by the bios on resume */
+	if (radeon_is_px(drm_dev)) {
+		pm_runtime_disable(dev);
+		pm_runtime_set_active(dev);
+		pm_runtime_enable(dev);
+	}
+
 	return radeon_resume_kms(drm_dev, true, true);
 }
 
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close
       [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (8 preceding siblings ...)
  2016-08-31 22:08   ` [PATCH 10/10] drm/radeon: set runtime pm state to active on resume Alex Deucher
@ 2016-09-01  1:03   ` Michel Dänzer
       [not found]     ` <6648435f-d52e-e4d3-55f4-df1837b3b8a8-otUistvHUpPR7s880joybQ@public.gmane.org>
  9 siblings, 1 reply; 19+ messages in thread
From: Michel Dänzer @ 2016-09-01  1:03 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 01/09/16 07:08 AM, Alex Deucher wrote:
> Close was not handled correctly.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index f1b9e0f..45f98b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -600,6 +600,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>  
>  	kfree(fpriv);
>  	file_priv->driver_priv = NULL;
> +
> +	pm_runtime_mark_last_busy(dev->dev);
> +	pm_runtime_put_autosuspend(dev->dev);
>  }
>  
>  /**
> @@ -614,6 +617,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>  void amdgpu_driver_preclose_kms(struct drm_device *dev,
>  				struct drm_file *file_priv)
>  {
> +	pm_runtime_get_sync(dev->dev);
>  }

What if pm_runtime_get_sync returns an error?

Same for patch 6.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 02/10] drm/amdgpu: handle runtime pm correctly in amdgpu_driver_open_kms
       [not found]     ` <1472681336-30106-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-09-01  1:04       ` Michel Dänzer
  0 siblings, 0 replies; 19+ messages in thread
From: Michel Dänzer @ 2016-09-01  1:04 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 01/09/16 07:08 AM, Alex Deucher wrote:
> Need to fix the error pathes.

Typo? "pathes"


> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 45f98b4..c2c7fb1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -542,12 +542,16 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>  		return r;
>  
>  	fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
> -	if (unlikely(!fpriv))
> -		return -ENOMEM;
> +	if (unlikely(!fpriv)) {
> +		r = -ENOMEM;
> +		goto out_suspend;
> +	}
>  
>  	r = amdgpu_vm_init(adev, &fpriv->vm);
> -	if (r)
> -		goto error_free;
> +	if (r) {
> +		kfree(fpriv);
> +		goto out_suspend;
> +	}
>  
>  	mutex_init(&fpriv->bo_list_lock);
>  	idr_init(&fpriv->bo_list_handles);
> @@ -556,12 +560,9 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>  
>  	file_priv->driver_priv = fpriv;
>  
> +out_suspend:
>  	pm_runtime_mark_last_busy(dev->dev);
>  	pm_runtime_put_autosuspend(dev->dev);
> -	return 0;
> -
> -error_free:
> -	kfree(fpriv);

This patch and patch 7 are

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
       [not found]     ` <1472681336-30106-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-09-01  1:04       ` Michel Dänzer
       [not found]         ` <c2ff0619-5d11-c443-a1b4-b57530dc89f6-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Michel Dänzer @ 2016-09-01  1:04 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 01/09/16 07:08 AM, Alex Deucher wrote:
> Ported from nouveau.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

[...]

> +static int
> +amdgpufb_open(struct fb_info *info, int user)
> +{
> +	struct amdgpu_fbdev *rfbdev = info->par;
> +	struct amdgpu_device *adev = rfbdev->adev;
> +	int ret = pm_runtime_get_sync(adev->ddev->dev);
> +	if (ret < 0 && ret != -EACCES)
> +		return ret;
> +	return 0;
> +}
> +
> +static int
> +amdgpufb_release(struct fb_info *info, int user)
> +{
> +	struct amdgpu_fbdev *rfbdev = info->par;
> +	struct amdgpu_device *adev = rfbdev->adev;
> +
> +	pm_runtime_mark_last_busy(adev->ddev->dev);
> +	pm_runtime_put_autosuspend(adev->ddev->dev);
> +	return 0;
> +}

If pm_runtime_get_sync returns -EACCES, won't there be an imbalance with
the pm_runtime_put_autosuspend call, which might result in the GPU
powering off even when there's something else which is supposed to keep
it on?

Same for patch 8.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 04/10] drm/amdgpu: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF
       [not found]     ` <1472681336-30106-4-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-09-01  1:06       ` Michel Dänzer
  0 siblings, 0 replies; 19+ messages in thread
From: Michel Dänzer @ 2016-09-01  1:06 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 01/09/16 07:08 AM, Alex Deucher wrote:
> Missed this case previously. No need to do anything if the
> device is already off.  runtime pm will handle it.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2f96334..e6b34dc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1842,7 +1842,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon,
>  
>  	adev = dev->dev_private;
>  
> -	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
> +	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
> +	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
>  		return 0;
>  
>  	drm_kms_helper_poll_disable(dev);
> @@ -1926,7 +1927,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon,
>  	struct drm_crtc *crtc;
>  	int r;
>  
> -	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
> +	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
> +	    dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
>  		return 0;
>  
>  	if (fbcon) {
> 

This patch and patches 5, 9 & 10 are

Acked-by: Michel Dänzer <michel.daenzer@amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close
       [not found]     ` <6648435f-d52e-e4d3-55f4-df1837b3b8a8-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-09-01 20:38       ` Alex Deucher
       [not found]         ` <CADnq5_N3e=xLhziKFKJog9vodd-=0sG4o2xW+kqU9ck+jFtMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-09-01 20:38 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: Alex Deucher, amd-gfx list

On Wed, Aug 31, 2016 at 9:03 PM, Michel Dänzer <michel@daenzer.net> wrote:
> On 01/09/16 07:08 AM, Alex Deucher wrote:
>> Close was not handled correctly.
>>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index f1b9e0f..45f98b4 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -600,6 +600,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>>
>>       kfree(fpriv);
>>       file_priv->driver_priv = NULL;
>> +
>> +     pm_runtime_mark_last_busy(dev->dev);
>> +     pm_runtime_put_autosuspend(dev->dev);
>>  }
>>
>>  /**
>> @@ -614,6 +617,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>>  void amdgpu_driver_preclose_kms(struct drm_device *dev,
>>                               struct drm_file *file_priv)
>>  {
>> +     pm_runtime_get_sync(dev->dev);
>>  }
>
> What if pm_runtime_get_sync returns an error?
>
> Same for patch 6.
>

I guess we could report it.  drm_release() doesn't check the return
value however.

Alex

>
> --
> Earthling Michel Dänzer               |               http://www.amd.com
> Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
       [not found]         ` <c2ff0619-5d11-c443-a1b4-b57530dc89f6-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-09-01 20:44           ` Alex Deucher
       [not found]             ` <CADnq5_P+HQ=7LQfFjG8dLihbGsEKnLZFNmeFeUdL79VvuwyqdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Alex Deucher @ 2016-09-01 20:44 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: Alex Deucher, amd-gfx list

On Wed, Aug 31, 2016 at 9:04 PM, Michel Dänzer <michel@daenzer.net> wrote:
> On 01/09/16 07:08 AM, Alex Deucher wrote:
>> Ported from nouveau.
>>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>
> [...]
>
>> +static int
>> +amdgpufb_open(struct fb_info *info, int user)
>> +{
>> +     struct amdgpu_fbdev *rfbdev = info->par;
>> +     struct amdgpu_device *adev = rfbdev->adev;
>> +     int ret = pm_runtime_get_sync(adev->ddev->dev);
>> +     if (ret < 0 && ret != -EACCES)
>> +             return ret;
>> +     return 0;
>> +}
>> +
>> +static int
>> +amdgpufb_release(struct fb_info *info, int user)
>> +{
>> +     struct amdgpu_fbdev *rfbdev = info->par;
>> +     struct amdgpu_device *adev = rfbdev->adev;
>> +
>> +     pm_runtime_mark_last_busy(adev->ddev->dev);
>> +     pm_runtime_put_autosuspend(adev->ddev->dev);
>> +     return 0;
>> +}
>
> If pm_runtime_get_sync returns -EACCES, won't there be an imbalance with
> the pm_runtime_put_autosuspend call, which might result in the GPU
> powering off even when there's something else which is supposed to keep
> it on?
>
> Same for patch 8.

pm_runtime_get_sync only returns -EACCES when runtime pm has been
disabled in which case the GPU is on and pm_runtime_put_autosuspend
won't do anything.

Alex

>
>
> --
> Earthling Michel Dänzer               |               http://www.amd.com
> Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
       [not found]             ` <CADnq5_P+HQ=7LQfFjG8dLihbGsEKnLZFNmeFeUdL79VvuwyqdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-09-02  1:47               ` Michel Dänzer
       [not found]                 ` <38837769-4dfc-8a19-b6de-c5d18014c889-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Michel Dänzer @ 2016-09-02  1:47 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx list

On 02/09/16 05:44 AM, Alex Deucher wrote:
> On Wed, Aug 31, 2016 at 9:04 PM, Michel Dänzer <michel@daenzer.net> wrote:
>> On 01/09/16 07:08 AM, Alex Deucher wrote:
>>> Ported from nouveau.
>>>
>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>
>> [...]
>>
>>> +static int
>>> +amdgpufb_open(struct fb_info *info, int user)
>>> +{
>>> +     struct amdgpu_fbdev *rfbdev = info->par;
>>> +     struct amdgpu_device *adev = rfbdev->adev;
>>> +     int ret = pm_runtime_get_sync(adev->ddev->dev);
>>> +     if (ret < 0 && ret != -EACCES)
>>> +             return ret;
>>> +     return 0;
>>> +}
>>> +
>>> +static int
>>> +amdgpufb_release(struct fb_info *info, int user)
>>> +{
>>> +     struct amdgpu_fbdev *rfbdev = info->par;
>>> +     struct amdgpu_device *adev = rfbdev->adev;
>>> +
>>> +     pm_runtime_mark_last_busy(adev->ddev->dev);
>>> +     pm_runtime_put_autosuspend(adev->ddev->dev);
>>> +     return 0;
>>> +}
>>
>> If pm_runtime_get_sync returns -EACCES, won't there be an imbalance with
>> the pm_runtime_put_autosuspend call, which might result in the GPU
>> powering off even when there's something else which is supposed to keep
>> it on?
>>
>> Same for patch 8.
> 
> pm_runtime_get_sync only returns -EACCES when runtime pm has been
> disabled in which case the GPU is on and pm_runtime_put_autosuspend
> won't do anything.

It decreases dev->power.usage_count, and my worry was that
pm_runtime_get_sync might not have increased it when it returns an
error. But it turns out that it does increase it unconditionally.


However, I'm afraid there seems to be another related problem: If
amdgpufb_open returns an error, amdgpufb_release won't be called AFAICT.
In which case amdgpufb_open needs to call pm_runtime_put_autosuspend in
the error case, or the GPU can never power off after that.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close
       [not found]         ` <CADnq5_N3e=xLhziKFKJog9vodd-=0sG4o2xW+kqU9ck+jFtMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-09-02  1:50           ` Michel Dänzer
  0 siblings, 0 replies; 19+ messages in thread
From: Michel Dänzer @ 2016-09-02  1:50 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx list

On 02/09/16 05:38 AM, Alex Deucher wrote:
> On Wed, Aug 31, 2016 at 9:03 PM, Michel Dänzer <michel@daenzer.net> wrote:
>> On 01/09/16 07:08 AM, Alex Deucher wrote:
>>> Close was not handled correctly.
>>>
>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> index f1b9e0f..45f98b4 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> @@ -600,6 +600,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>>>
>>>       kfree(fpriv);
>>>       file_priv->driver_priv = NULL;
>>> +
>>> +     pm_runtime_mark_last_busy(dev->dev);
>>> +     pm_runtime_put_autosuspend(dev->dev);
>>>  }
>>>
>>>  /**
>>> @@ -614,6 +617,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>>>  void amdgpu_driver_preclose_kms(struct drm_device *dev,
>>>                               struct drm_file *file_priv)
>>>  {
>>> +     pm_runtime_get_sync(dev->dev);
>>>  }
>>
>> What if pm_runtime_get_sync returns an error?
>>
>> Same for patch 6.
> 
> I guess we could report it.

Based on the discussion of patch 3, it doesn't seem necessary. So this
patch and patch 6 are

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* RE: [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
       [not found]                 ` <38837769-4dfc-8a19-b6de-c5d18014c889-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-09-02 13:31                   ` Deucher, Alexander
  0 siblings, 0 replies; 19+ messages in thread
From: Deucher, Alexander @ 2016-09-02 13:31 UTC (permalink / raw)
  To: 'Michel Dänzer', Alex Deucher; +Cc: amd-gfx list

> -----Original Message-----
> From: Michel Dänzer [mailto:michel@daenzer.net]
> Sent: Thursday, September 01, 2016 9:47 PM
> To: Alex Deucher
> Cc: amd-gfx list; Deucher, Alexander
> Subject: Re: [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon
> 
> On 02/09/16 05:44 AM, Alex Deucher wrote:
> > On Wed, Aug 31, 2016 at 9:04 PM, Michel Dänzer <michel@daenzer.net>
> wrote:
> >> On 01/09/16 07:08 AM, Alex Deucher wrote:
> >>> Ported from nouveau.
> >>>
> >>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> >>
> >> [...]
> >>
> >>> +static int
> >>> +amdgpufb_open(struct fb_info *info, int user)
> >>> +{
> >>> +     struct amdgpu_fbdev *rfbdev = info->par;
> >>> +     struct amdgpu_device *adev = rfbdev->adev;
> >>> +     int ret = pm_runtime_get_sync(adev->ddev->dev);
> >>> +     if (ret < 0 && ret != -EACCES)
> >>> +             return ret;
> >>> +     return 0;
> >>> +}
> >>> +
> >>> +static int
> >>> +amdgpufb_release(struct fb_info *info, int user)
> >>> +{
> >>> +     struct amdgpu_fbdev *rfbdev = info->par;
> >>> +     struct amdgpu_device *adev = rfbdev->adev;
> >>> +
> >>> +     pm_runtime_mark_last_busy(adev->ddev->dev);
> >>> +     pm_runtime_put_autosuspend(adev->ddev->dev);
> >>> +     return 0;
> >>> +}
> >>
> >> If pm_runtime_get_sync returns -EACCES, won't there be an imbalance
> with
> >> the pm_runtime_put_autosuspend call, which might result in the GPU
> >> powering off even when there's something else which is supposed to
> keep
> >> it on?
> >>
> >> Same for patch 8.
> >
> > pm_runtime_get_sync only returns -EACCES when runtime pm has been
> > disabled in which case the GPU is on and pm_runtime_put_autosuspend
> > won't do anything.
> 
> It decreases dev->power.usage_count, and my worry was that
> pm_runtime_get_sync might not have increased it when it returns an
> error. But it turns out that it does increase it unconditionally.
> 
> 
> However, I'm afraid there seems to be another related problem: If
> amdgpufb_open returns an error, amdgpufb_release won't be called
> AFAICT.
> In which case amdgpufb_open needs to call pm_runtime_put_autosuspend
> in
> the error case, or the GPU can never power off after that.

Good point.  I'll fix that up.

Alex

> 
> 
> --
> Earthling Michel Dänzer               |               http://www.amd.com
> Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2016-09-02 13:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31 22:08 [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close Alex Deucher
     [not found] ` <1472681336-30106-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-08-31 22:08   ` [PATCH 02/10] drm/amdgpu: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
     [not found]     ` <1472681336-30106-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-09-01  1:04       ` Michel Dänzer
2016-08-31 22:08   ` [PATCH 03/10] drm/amdgpu: handle runtime pm in fbcon Alex Deucher
     [not found]     ` <1472681336-30106-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-09-01  1:04       ` Michel Dänzer
     [not found]         ` <c2ff0619-5d11-c443-a1b4-b57530dc89f6-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-01 20:44           ` Alex Deucher
     [not found]             ` <CADnq5_P+HQ=7LQfFjG8dLihbGsEKnLZFNmeFeUdL79VvuwyqdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-02  1:47               ` Michel Dänzer
     [not found]                 ` <38837769-4dfc-8a19-b6de-c5d18014c889-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-02 13:31                   ` Deucher, Alexander
2016-08-31 22:08   ` [PATCH 04/10] drm/amdgpu: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
     [not found]     ` <1472681336-30106-4-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-09-01  1:06       ` Michel Dänzer
2016-08-31 22:08   ` [PATCH 05/10] drm/amdgpu: set runtime pm state to active on resume Alex Deucher
2016-08-31 22:08   ` [PATCH 06/10] drm/radeon: handle runtime pm in drm pre/post close Alex Deucher
2016-08-31 22:08   ` [PATCH 07/10] drm/radeon: handle runtime pm correctly in amdgpu_driver_open_kms Alex Deucher
2016-08-31 22:08   ` [PATCH 08/10] drm/radeon: handle runtime pm in fbcon Alex Deucher
2016-08-31 22:08   ` [PATCH 09/10] drm/radeon: skip suspend/resume on DRM_SWITCH_POWER_DYNAMIC_OFF Alex Deucher
2016-08-31 22:08   ` [PATCH 10/10] drm/radeon: set runtime pm state to active on resume Alex Deucher
2016-09-01  1:03   ` [PATCH 01/10] drm/amdgpu: handle runtime pm in drm pre/post close Michel Dänzer
     [not found]     ` <6648435f-d52e-e4d3-55f4-df1837b3b8a8-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-01 20:38       ` Alex Deucher
     [not found]         ` <CADnq5_N3e=xLhziKFKJog9vodd-=0sG4o2xW+kqU9ck+jFtMYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-02  1:50           ` Michel Dänzer

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