All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Improve PX support in radeon and amdgpu
@ 2016-06-01 20:53 Alex Deucher
  2016-06-01 20:53 ` [PATCH 01/12] drm/amdgpu: disable power control on hybrid laptops Alex Deucher
                   ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

This patch set cleans up and attempts to make runtime pm more
reliable in radeon and amdgpu on PX systems.  If you have a PX
system that requires setting the runpm=0 module parameter for
stability, please try this patch set.

The main fix is that a minimum of 200ms of delay is required between
a dGPU power down and a power up.

This patch also properly handles the detection of the ATPX dGPU
power control method properly and handles dGPU power control for
platforms that do not support the ATPX dGPU power control method.

Alex Deucher (12):
  drm/amdgpu: disable power control on hybrid laptops
  drm/amdgpu: clean up atpx power control handling
  drm/amdgpu: add a delay after ATPX dGPU power off
  drm/amdgpu/atpx: add a query for ATPX dGPU power control
  drm/amdgpu: use PCI_D3hot for PX systems without dGPU power control
  drm/amdgpu/atpx: drop forcing of dGPU power control
  drm/radeon: disable power control on hybrid laptops
  drm/radeon: clean up atpx power control handling
  drm/radeon: add a delay after ATPX dGPU power off
  drm/radeon/atpx: add a query for ATPX dGPU power control
  drm/radeon: use PCI_D3hot for PX systems without dGPU power control
  drm/radeon/atpx: drop forcing of dGPU power control

 drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 50 ++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c          |  5 ++-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 49 +++++++++++++++--------
 drivers/gpu/drm/radeon/radeon_drv.c              |  7 +++-
 5 files changed, 77 insertions(+), 36 deletions(-)

-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 01/12] drm/amdgpu: disable power control on hybrid laptops
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 02/12] drm/amdgpu: clean up atpx power control handling Alex Deucher
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

Windows 10 (and some 8.1) systems use standardized
ACPI calls for hybrid laptops to control dGPU power.
Detect those cases and disable the AMD specific ATPX
power control.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 35a1248..3af1c3a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -183,6 +183,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
 				  ATPX_DFP_SIGNAL_MUXED))
 			atpx->functions.disp_mux_cntl = true;
 
+		if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
+			printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
+			atpx->functions.power_cntl = false;
+		}
+
 		kfree(info);
 	}
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 02/12] drm/amdgpu: clean up atpx power control handling
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
  2016-06-01 20:53 ` [PATCH 01/12] drm/amdgpu: disable power control on hybrid laptops Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 03/12] drm/amdgpu: add a delay after ATPX dGPU power off Alex Deucher
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

The presence of the power control method should be determined
via the presence of the method in function 0.  However, some
sbioses only set the appropriate bits in function 1 so use
then to override a missing power control function.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 3af1c3a..1be2ce4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -142,18 +142,12 @@ static void amdgpu_atpx_parse_functions(struct amdgpu_atpx_functions *f, u32 mas
  */
 static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
 {
-	/* make sure required functions are enabled */
-	/* dGPU power control is required */
-	if (atpx->functions.power_cntl == false) {
-		printk("ATPX dGPU power cntl not present, forcing\n");
-		atpx->functions.power_cntl = true;
-	}
+	u32 valid_bits = 0;
 
 	if (atpx->functions.px_params) {
 		union acpi_object *info;
 		struct atpx_px_params output;
 		size_t size;
-		u32 valid_bits;
 
 		info = amdgpu_atpx_call(atpx->handle, ATPX_FUNCTION_GET_PX_PARAMETERS, NULL);
 		if (!info)
@@ -172,24 +166,37 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
 		memcpy(&output, info->buffer.pointer, size);
 
 		valid_bits = output.flags & output.valid_flags;
-		/* if separate mux flag is set, mux controls are required */
-		if (valid_bits & ATPX_SEPARATE_MUX_FOR_I2C) {
-			atpx->functions.i2c_mux_cntl = true;
-			atpx->functions.disp_mux_cntl = true;
-		}
-		/* if any outputs are muxed, mux controls are required */
-		if (valid_bits & (ATPX_CRT1_RGB_SIGNAL_MUXED |
-				  ATPX_TV_SIGNAL_MUXED |
-				  ATPX_DFP_SIGNAL_MUXED))
-			atpx->functions.disp_mux_cntl = true;
-
-		if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
-			printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
-			atpx->functions.power_cntl = false;
-		}
 
 		kfree(info);
 	}
+
+	/* if separate mux flag is set, mux controls are required */
+	if (valid_bits & ATPX_SEPARATE_MUX_FOR_I2C) {
+		atpx->functions.i2c_mux_cntl = true;
+		atpx->functions.disp_mux_cntl = true;
+	}
+	/* if any outputs are muxed, mux controls are required */
+	if (valid_bits & (ATPX_CRT1_RGB_SIGNAL_MUXED |
+			  ATPX_TV_SIGNAL_MUXED |
+			  ATPX_DFP_SIGNAL_MUXED))
+		atpx->functions.disp_mux_cntl = true;
+
+
+	/* some bioses set these bits rather than flagging power_cntl as supported */
+	if (valid_bits & (ATPX_DYNAMIC_PX_SUPPORTED |
+			  ATPX_DYNAMIC_DGPU_POWER_OFF_SUPPORTED))
+		atpx->functions.power_cntl = true;
+
+	if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
+		printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
+		atpx->functions.power_cntl = false;
+	} else if (atpx->functions.power_cntl == false) {
+		/* make sure required functions are enabled */
+		/* dGPU power control is required */
+		printk("ATPX dGPU power cntl not present, forcing\n");
+		atpx->functions.power_cntl = true;
+	}
+
 	return 0;
 }
 
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 03/12] drm/amdgpu: add a delay after ATPX dGPU power off
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
  2016-06-01 20:53 ` [PATCH 01/12] drm/amdgpu: disable power control on hybrid laptops Alex Deucher
  2016-06-01 20:53 ` [PATCH 02/12] drm/amdgpu: clean up atpx power control handling Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 04/12] drm/amdgpu/atpx: add a query for ATPX dGPU power control Alex Deucher
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, stable

ATPX dGPU power control requires a 200ms delay between
power off and on.  This should fix dGPU failures on
resume from power off.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 1be2ce4..c5d280c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 
 #include "amd_acpi.h"
 
@@ -271,6 +272,10 @@ static int amdgpu_atpx_set_discrete_state(struct amdgpu_atpx *atpx, u8 state)
 		if (!info)
 			return -EIO;
 		kfree(info);
+
+		/* 200ms delay is required after off */
+		if (state == 0)
+			msleep(200);
 	}
 	return 0;
 }
-- 
2.5.5


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

* [PATCH 04/12] drm/amdgpu/atpx: add a query for ATPX dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (2 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 03/12] drm/amdgpu: add a delay after ATPX dGPU power off Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 05/12] drm/amdgpu: use PCI_D3hot for PX systems without " Alex Deucher
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

The runtime pm sequence is different depending on whether or
not the platform supports ATPX dGPU power control.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index ab122cc4..19d15dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2393,9 +2393,11 @@ bool amdgpu_device_is_px(struct drm_device *dev);
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
 void amdgpu_unregister_atpx_handler(void);
+bool amdgpu_has_atpx_dgpu_power_cntl(void);
 #else
 static inline void amdgpu_register_atpx_handler(void) {}
 static inline void amdgpu_unregister_atpx_handler(void) {}
+static inline bool amdgpu_has_atpx_dgpu_power_cntl(void) { return false; }
 #endif
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index c5d280c..7b11af1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -64,6 +64,10 @@ bool amdgpu_has_atpx(void) {
 	return amdgpu_atpx_priv.atpx_detected;
 }
 
+bool amdgpu_has_atpx_dgpu_power_cntl(void) {
+	return amdgpu_atpx_priv.atpx.functions.power_cntl;
+}
+
 /**
  * amdgpu_atpx_call - call an ATPX method
  *
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 05/12] drm/amdgpu: use PCI_D3hot for PX systems without dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (3 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 04/12] drm/amdgpu/atpx: add a query for ATPX dGPU power control Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 06/12] drm/amdgpu/atpx: drop forcing of " Alex Deucher
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

On PX systems without dGPU power control, use PCI_D3hot.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index f122703..7e49bf4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -417,7 +417,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_ignore_hotplug(pdev);
-	pci_set_power_state(pdev, PCI_D3cold);
+	if (amdgpu_has_atpx_dgpu_power_cntl())
+		pci_set_power_state(pdev, PCI_D3cold);
+	else
+		pci_set_power_state(pdev, PCI_D3hot);
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
 
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 06/12] drm/amdgpu/atpx: drop forcing of dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (4 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 05/12] drm/amdgpu: use PCI_D3hot for PX systems without " Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 07/12] drm/radeon: disable power control on hybrid laptops Alex Deucher
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

Now that we handle this correctly, there is no need to force
it.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 7b11af1..90dfedc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -195,11 +195,6 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
 	if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
 		printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
 		atpx->functions.power_cntl = false;
-	} else if (atpx->functions.power_cntl == false) {
-		/* make sure required functions are enabled */
-		/* dGPU power control is required */
-		printk("ATPX dGPU power cntl not present, forcing\n");
-		atpx->functions.power_cntl = true;
 	}
 
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 07/12] drm/radeon: disable power control on hybrid laptops
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (5 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 06/12] drm/amdgpu/atpx: drop forcing of " Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 08/12] drm/radeon: clean up atpx power control handling Alex Deucher
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

Windows 10 (and some 8.1) systems use standardized
ACPI calls for hybrid laptops to control dGPU power.
Detect those cases and disable the AMD specific ATPX
power control.

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

diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 95f4fea..3e24fe0 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -182,6 +182,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
 				  ATPX_DFP_SIGNAL_MUXED))
 			atpx->functions.disp_mux_cntl = true;
 
+		if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
+			printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
+			atpx->functions.power_cntl = false;
+		}
+
 		kfree(info);
 	}
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 08/12] drm/radeon: clean up atpx power control handling
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (6 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 07/12] drm/radeon: disable power control on hybrid laptops Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 09/12] drm/radeon: add a delay after ATPX dGPU power off Alex Deucher
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

The presence of the power control method should be determined
via the presence of the method in function 0.  However, some
sbioses only set the appropriate bits in function 1 so use
then to override a missing power control function.

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

diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 3e24fe0..55efbcd 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -141,18 +141,12 @@ static void radeon_atpx_parse_functions(struct radeon_atpx_functions *f, u32 mas
  */
 static int radeon_atpx_validate(struct radeon_atpx *atpx)
 {
-	/* make sure required functions are enabled */
-	/* dGPU power control is required */
-	if (atpx->functions.power_cntl == false) {
-		printk("ATPX dGPU power cntl not present, forcing\n");
-		atpx->functions.power_cntl = true;
-	}
+	u32 valid_bits = 0;
 
 	if (atpx->functions.px_params) {
 		union acpi_object *info;
 		struct atpx_px_params output;
 		size_t size;
-		u32 valid_bits;
 
 		info = radeon_atpx_call(atpx->handle, ATPX_FUNCTION_GET_PX_PARAMETERS, NULL);
 		if (!info)
@@ -171,24 +165,36 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
 		memcpy(&output, info->buffer.pointer, size);
 
 		valid_bits = output.flags & output.valid_flags;
-		/* if separate mux flag is set, mux controls are required */
-		if (valid_bits & ATPX_SEPARATE_MUX_FOR_I2C) {
-			atpx->functions.i2c_mux_cntl = true;
-			atpx->functions.disp_mux_cntl = true;
-		}
-		/* if any outputs are muxed, mux controls are required */
-		if (valid_bits & (ATPX_CRT1_RGB_SIGNAL_MUXED |
-				  ATPX_TV_SIGNAL_MUXED |
-				  ATPX_DFP_SIGNAL_MUXED))
-			atpx->functions.disp_mux_cntl = true;
-
-		if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
-			printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
-			atpx->functions.power_cntl = false;
-		}
 
 		kfree(info);
 	}
+
+	/* if separate mux flag is set, mux controls are required */
+	if (valid_bits & ATPX_SEPARATE_MUX_FOR_I2C) {
+		atpx->functions.i2c_mux_cntl = true;
+		atpx->functions.disp_mux_cntl = true;
+	}
+	/* if any outputs are muxed, mux controls are required */
+	if (valid_bits & (ATPX_CRT1_RGB_SIGNAL_MUXED |
+			  ATPX_TV_SIGNAL_MUXED |
+			  ATPX_DFP_SIGNAL_MUXED))
+		atpx->functions.disp_mux_cntl = true;
+
+	/* some bioses set these bits rather than flagging power_cntl as supported */
+	if (valid_bits & (ATPX_DYNAMIC_PX_SUPPORTED |
+			  ATPX_DYNAMIC_DGPU_POWER_OFF_SUPPORTED))
+		atpx->functions.power_cntl = true;
+
+	if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
+		printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
+		atpx->functions.power_cntl = false;
+	} else if (atpx->functions.power_cntl == false) {
+		/* make sure required functions are enabled */
+		/* dGPU power control is required */
+		printk("ATPX dGPU power cntl not present, forcing\n");
+		atpx->functions.power_cntl = true;
+	}
+
 	return 0;
 }
 
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 09/12] drm/radeon: add a delay after ATPX dGPU power off
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (7 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 08/12] drm/radeon: clean up atpx power control handling Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 10/12] drm/radeon/atpx: add a query for ATPX dGPU power control Alex Deucher
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, stable

ATPX dGPU power control requires a 200ms delay between
power off and on.  This should fix dGPU failures on
resume from power off.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/radeon/radeon_atpx_handler.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 55efbcd..3d95194 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 
 #include "radeon_acpi.h"
 
@@ -269,6 +270,10 @@ static int radeon_atpx_set_discrete_state(struct radeon_atpx *atpx, u8 state)
 		if (!info)
 			return -EIO;
 		kfree(info);
+
+		/* 200ms delay is required after off */
+		if (state == 0)
+			msleep(200);
 	}
 	return 0;
 }
-- 
2.5.5


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

* [PATCH 10/12] drm/radeon/atpx: add a query for ATPX dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (8 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 09/12] drm/radeon: add a delay after ATPX dGPU power off Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 11/12] drm/radeon: use PCI_D3hot for PX systems without " Alex Deucher
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

The runtime pm sequence is different depending on whether or
not the platform supports ATPX dGPU power control.

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

diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 3d95194..51da319 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -63,6 +63,10 @@ bool radeon_has_atpx(void) {
 	return radeon_atpx_priv.atpx_detected;
 }
 
+bool radeon_has_atpx_dgpu_power_cntl(void) {
+	return radeon_atpx_priv.atpx.functions.power_cntl;
+}
+
 /**
  * radeon_atpx_call - call an ATPX method
  *
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 36242a9..2dc43f5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -165,9 +165,11 @@ void radeon_debugfs_cleanup(struct drm_minor *minor);
 #if defined(CONFIG_VGA_SWITCHEROO)
 void radeon_register_atpx_handler(void);
 void radeon_unregister_atpx_handler(void);
+bool radeon_has_atpx_dgpu_power_cntl(void);
 #else
 static inline void radeon_register_atpx_handler(void) {}
 static inline void radeon_unregister_atpx_handler(void) {}
+static inline bool radeon_has_atpx_dgpu_power_cntl(void) { return false; }
 #endif
 
 int radeon_no_wb;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 11/12] drm/radeon: use PCI_D3hot for PX systems without dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (9 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 10/12] drm/radeon/atpx: add a query for ATPX dGPU power control Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-01 20:53 ` [PATCH 12/12] drm/radeon/atpx: drop forcing of " Alex Deucher
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

On PX systems without dGPU power control, use PCI_D3hot.

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

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 2dc43f5..ec80050 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -415,7 +415,10 @@ static int radeon_pmops_runtime_suspend(struct device *dev)
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_ignore_hotplug(pdev);
-	pci_set_power_state(pdev, PCI_D3cold);
+	if (radeon_has_atpx_dgpu_power_cntl())
+		pci_set_power_state(pdev, PCI_D3cold);
+	else
+		pci_set_power_state(pdev, PCI_D3hot);
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
 
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 12/12] drm/radeon/atpx: drop forcing of dGPU power control
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (10 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 11/12] drm/radeon: use PCI_D3hot for PX systems without " Alex Deucher
@ 2016-06-01 20:53 ` Alex Deucher
  2016-06-02  0:02 ` [PATCH 00/12] Improve PX support in radeon and amdgpu Mike Lothian
  2016-06-02  7:17 ` Christian König
  13 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-01 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

Now that we handle this correctly, there is no need to force
it.

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

diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 51da319..6996b31 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -193,11 +193,6 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
 	if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
 		printk("Hybrid Graphics, ATPX dGPU power cntl disabled\n");
 		atpx->functions.power_cntl = false;
-	} else if (atpx->functions.power_cntl == false) {
-		/* make sure required functions are enabled */
-		/* dGPU power control is required */
-		printk("ATPX dGPU power cntl not present, forcing\n");
-		atpx->functions.power_cntl = true;
 	}
 
 	return 0;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 00/12] Improve PX support in radeon and amdgpu
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (11 preceding siblings ...)
  2016-06-01 20:53 ` [PATCH 12/12] drm/radeon/atpx: drop forcing of " Alex Deucher
@ 2016-06-02  0:02 ` Mike Lothian
  2016-06-02 12:31   ` Alex Deucher
  2016-06-02  7:17 ` Christian König
  13 siblings, 1 reply; 16+ messages in thread
From: Mike Lothian @ 2016-06-02  0:02 UTC (permalink / raw)
  To: Alex Deucher, dri-devel; +Cc: Alex Deucher


[-- Attachment #1.1: Type: text/plain, Size: 2033 bytes --]

Are these in a branch somewhere? If not I'll try apply the mbox from
patchwork.freedesktop.org

On Wed, 1 Jun 2016 at 21:53 Alex Deucher <alexdeucher@gmail.com> wrote:

> This patch set cleans up and attempts to make runtime pm more
> reliable in radeon and amdgpu on PX systems.  If you have a PX
> system that requires setting the runpm=0 module parameter for
> stability, please try this patch set.
>
> The main fix is that a minimum of 200ms of delay is required between
> a dGPU power down and a power up.
>
> This patch also properly handles the detection of the ATPX dGPU
> power control method properly and handles dGPU power control for
> platforms that do not support the ATPX dGPU power control method.
>
> Alex Deucher (12):
>   drm/amdgpu: disable power control on hybrid laptops
>   drm/amdgpu: clean up atpx power control handling
>   drm/amdgpu: add a delay after ATPX dGPU power off
>   drm/amdgpu/atpx: add a query for ATPX dGPU power control
>   drm/amdgpu: use PCI_D3hot for PX systems without dGPU power control
>   drm/amdgpu/atpx: drop forcing of dGPU power control
>   drm/radeon: disable power control on hybrid laptops
>   drm/radeon: clean up atpx power control handling
>   drm/radeon: add a delay after ATPX dGPU power off
>   drm/radeon/atpx: add a query for ATPX dGPU power control
>   drm/radeon: use PCI_D3hot for PX systems without dGPU power control
>   drm/radeon/atpx: drop forcing of dGPU power control
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  2 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 50
> ++++++++++++++++--------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c          |  5 ++-
>  drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 49
> +++++++++++++++--------
>  drivers/gpu/drm/radeon/radeon_drv.c              |  7 +++-
>  5 files changed, 77 insertions(+), 36 deletions(-)
>
> --
> 2.5.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

[-- Attachment #1.2: Type: text/html, Size: 2664 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 00/12] Improve PX support in radeon and amdgpu
  2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
                   ` (12 preceding siblings ...)
  2016-06-02  0:02 ` [PATCH 00/12] Improve PX support in radeon and amdgpu Mike Lothian
@ 2016-06-02  7:17 ` Christian König
  13 siblings, 0 replies; 16+ messages in thread
From: Christian König @ 2016-06-02  7:17 UTC (permalink / raw)
  To: Alex Deucher, dri-devel; +Cc: Alex Deucher

Am 01.06.2016 um 22:53 schrieb Alex Deucher:
> This patch set cleans up and attempts to make runtime pm more
> reliable in radeon and amdgpu on PX systems.  If you have a PX
> system that requires setting the runpm=0 module parameter for
> stability, please try this patch set.
>
> The main fix is that a minimum of 200ms of delay is required between
> a dGPU power down and a power up.
>
> This patch also properly handles the detection of the ATPX dGPU
> power control method properly and handles dGPU power control for
> platforms that do not support the ATPX dGPU power control method.

Acked-by: Christian König <christian.koenig@amd.com> for the whole series.

>
> Alex Deucher (12):
>    drm/amdgpu: disable power control on hybrid laptops
>    drm/amdgpu: clean up atpx power control handling
>    drm/amdgpu: add a delay after ATPX dGPU power off
>    drm/amdgpu/atpx: add a query for ATPX dGPU power control
>    drm/amdgpu: use PCI_D3hot for PX systems without dGPU power control
>    drm/amdgpu/atpx: drop forcing of dGPU power control
>    drm/radeon: disable power control on hybrid laptops
>    drm/radeon: clean up atpx power control handling
>    drm/radeon: add a delay after ATPX dGPU power off
>    drm/radeon/atpx: add a query for ATPX dGPU power control
>    drm/radeon: use PCI_D3hot for PX systems without dGPU power control
>    drm/radeon/atpx: drop forcing of dGPU power control
>
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  2 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 50 ++++++++++++++++--------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c          |  5 ++-
>   drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 49 +++++++++++++++--------
>   drivers/gpu/drm/radeon/radeon_drv.c              |  7 +++-
>   5 files changed, 77 insertions(+), 36 deletions(-)
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 00/12] Improve PX support in radeon and amdgpu
  2016-06-02  0:02 ` [PATCH 00/12] Improve PX support in radeon and amdgpu Mike Lothian
@ 2016-06-02 12:31   ` Alex Deucher
  0 siblings, 0 replies; 16+ messages in thread
From: Alex Deucher @ 2016-06-02 12:31 UTC (permalink / raw)
  To: Mike Lothian; +Cc: Alex Deucher, Maling list - DRI developers

On Wed, Jun 1, 2016 at 8:02 PM, Mike Lothian <mike@fireburn.co.uk> wrote:
> Are these in a branch somewhere? If not I'll try apply the mbox from
> patchwork.freedesktop.org
>

Just pushed to my drm-next-4.8-wip branch.

Alex

> On Wed, 1 Jun 2016 at 21:53 Alex Deucher <alexdeucher@gmail.com> wrote:
>>
>> This patch set cleans up and attempts to make runtime pm more
>> reliable in radeon and amdgpu on PX systems.  If you have a PX
>> system that requires setting the runpm=0 module parameter for
>> stability, please try this patch set.
>>
>> The main fix is that a minimum of 200ms of delay is required between
>> a dGPU power down and a power up.
>>
>> This patch also properly handles the detection of the ATPX dGPU
>> power control method properly and handles dGPU power control for
>> platforms that do not support the ATPX dGPU power control method.
>>
>> Alex Deucher (12):
>>   drm/amdgpu: disable power control on hybrid laptops
>>   drm/amdgpu: clean up atpx power control handling
>>   drm/amdgpu: add a delay after ATPX dGPU power off
>>   drm/amdgpu/atpx: add a query for ATPX dGPU power control
>>   drm/amdgpu: use PCI_D3hot for PX systems without dGPU power control
>>   drm/amdgpu/atpx: drop forcing of dGPU power control
>>   drm/radeon: disable power control on hybrid laptops
>>   drm/radeon: clean up atpx power control handling
>>   drm/radeon: add a delay after ATPX dGPU power off
>>   drm/radeon/atpx: add a query for ATPX dGPU power control
>>   drm/radeon: use PCI_D3hot for PX systems without dGPU power control
>>   drm/radeon/atpx: drop forcing of dGPU power control
>>
>>  drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  2 +
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 50
>> ++++++++++++++++--------
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c          |  5 ++-
>>  drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 49
>> +++++++++++++++--------
>>  drivers/gpu/drm/radeon/radeon_drv.c              |  7 +++-
>>  5 files changed, 77 insertions(+), 36 deletions(-)
>>
>> --
>> 2.5.5
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

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

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 20:53 [PATCH 00/12] Improve PX support in radeon and amdgpu Alex Deucher
2016-06-01 20:53 ` [PATCH 01/12] drm/amdgpu: disable power control on hybrid laptops Alex Deucher
2016-06-01 20:53 ` [PATCH 02/12] drm/amdgpu: clean up atpx power control handling Alex Deucher
2016-06-01 20:53 ` [PATCH 03/12] drm/amdgpu: add a delay after ATPX dGPU power off Alex Deucher
2016-06-01 20:53 ` [PATCH 04/12] drm/amdgpu/atpx: add a query for ATPX dGPU power control Alex Deucher
2016-06-01 20:53 ` [PATCH 05/12] drm/amdgpu: use PCI_D3hot for PX systems without " Alex Deucher
2016-06-01 20:53 ` [PATCH 06/12] drm/amdgpu/atpx: drop forcing of " Alex Deucher
2016-06-01 20:53 ` [PATCH 07/12] drm/radeon: disable power control on hybrid laptops Alex Deucher
2016-06-01 20:53 ` [PATCH 08/12] drm/radeon: clean up atpx power control handling Alex Deucher
2016-06-01 20:53 ` [PATCH 09/12] drm/radeon: add a delay after ATPX dGPU power off Alex Deucher
2016-06-01 20:53 ` [PATCH 10/12] drm/radeon/atpx: add a query for ATPX dGPU power control Alex Deucher
2016-06-01 20:53 ` [PATCH 11/12] drm/radeon: use PCI_D3hot for PX systems without " Alex Deucher
2016-06-01 20:53 ` [PATCH 12/12] drm/radeon/atpx: drop forcing of " Alex Deucher
2016-06-02  0:02 ` [PATCH 00/12] Improve PX support in radeon and amdgpu Mike Lothian
2016-06-02 12:31   ` Alex Deucher
2016-06-02  7:17 ` Christian König

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.