All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support
@ 2016-09-14 18:49 Alex Deucher
       [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2016-09-14 18:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Some ATPX laptops implement special circuitry to generate
display hotplug events via ACPI when the dGPU is powered off.
Check if this is supported.

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 | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 588baaf..681e920 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2463,11 +2463,13 @@ void amdgpu_register_atpx_handler(void);
 void amdgpu_unregister_atpx_handler(void);
 bool amdgpu_has_atpx_dgpu_power_cntl(void);
 bool amdgpu_is_atpx_hybrid(void);
+bool amdgpu_atpx_dgpu_req_power_for_displays(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; }
 static inline bool amdgpu_is_atpx_hybrid(void) { return false; }
+static inline bool amdgpu_atpx_dgpu_req_power_for_displays(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 49de926..550c5ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -29,6 +29,7 @@ struct amdgpu_atpx {
 	acpi_handle handle;
 	struct amdgpu_atpx_functions functions;
 	bool is_hybrid;
+	bool dgpu_req_power_for_displays;
 };
 
 static struct amdgpu_atpx_priv {
@@ -73,6 +74,10 @@ bool amdgpu_is_atpx_hybrid(void) {
 	return amdgpu_atpx_priv.atpx.is_hybrid;
 }
 
+bool amdgpu_atpx_dgpu_req_power_for_displays(void) {
+	return amdgpu_atpx_priv.atpx.dgpu_req_power_for_displays;
+}
+
 /**
  * amdgpu_atpx_call - call an ATPX method
  *
@@ -213,6 +218,10 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
 		atpx->is_hybrid = true;
 	}
 
+	atpx->dgpu_req_power_for_displays = false;
+	if (valid_bits & ATPX_DGPU_REQ_POWER_FOR_DISPLAYS)
+		atpx->dgpu_req_power_for_displays = true;
+
 	return 0;
 }
 
-- 
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] 6+ messages in thread

* [PATCH 2/4] drm/amdgpu/atif: Send a hotplug event when we get dgpu display request
       [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-09-14 18:49   ` Alex Deucher
  2016-09-14 18:49   ` [PATCH 3/4] drm/radeon/atpx: check for ATIF dGPU wake for display events support Alex Deucher
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2016-09-14 18:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

On PX systems, if the platform supports hotplug events ATIF while the
dGPU is powered down, handle the event and alert userspace.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 5cd7b73..5796539 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -25,6 +25,7 @@
 #include <linux/acpi.h>
 #include <linux/slab.h>
 #include <linux/power_supply.h>
+#include <linux/pm_runtime.h>
 #include <acpi/video.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
@@ -333,6 +334,16 @@ int amdgpu_atif_handler(struct amdgpu_device *adev,
 #endif
 		}
 	}
+	if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
+		if ((adev->flags & AMD_IS_PX) &&
+		    amdgpu_atpx_dgpu_req_power_for_displays()) {
+			pm_runtime_get_sync(adev->ddev->dev);
+			/* Just fire off a uevent and let userspace tell us what to do */
+			drm_helper_hpd_irq_event(adev->ddev);
+			pm_runtime_mark_last_busy(adev->ddev->dev);
+			pm_runtime_put_autosuspend(adev->ddev->dev);
+		}
+	}
 	/* TODO: check other events */
 
 	/* We've handled the event, stop the notifier chain. The ACPI interface
-- 
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] 6+ messages in thread

* [PATCH 3/4] drm/radeon/atpx: check for ATIF dGPU wake for display events support
       [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-09-14 18:49   ` [PATCH 2/4] drm/amdgpu/atif: Send a hotplug event when we get dgpu display request Alex Deucher
@ 2016-09-14 18:49   ` Alex Deucher
       [not found]     ` <1473878944-30900-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-09-14 18:49   ` [PATCH 4/4] drm/radeon/atif: Send a hotplug event when we get dgpu display request Alex Deucher
  2016-09-19 16:00   ` [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support Alex Deucher
  3 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2016-09-14 18:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Some ATPX laptops implement special circuitry to generate
display hotplug events via ACPI when the dGPU is powered off.
Check if this is supported.

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 6de3428..a1321b2 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -29,6 +29,7 @@ struct radeon_atpx {
 	acpi_handle handle;
 	struct radeon_atpx_functions functions;
 	bool is_hybrid;
+	bool dgpu_req_power_for_displays;
 };
 
 static struct radeon_atpx_priv {
@@ -72,6 +73,10 @@ bool radeon_is_atpx_hybrid(void) {
 	return radeon_atpx_priv.atpx.is_hybrid;
 }
 
+bool radeon_atpx_dgpu_req_power_for_displays(void) {
+	return radeon_atpx_priv.atpx.dgpu_req_power_for_displays;
+}
+
 /**
  * radeon_atpx_call - call an ATPX method
  *
-- 
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] 6+ messages in thread

* [PATCH 4/4] drm/radeon/atif: Send a hotplug event when we get dgpu display request
       [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-09-14 18:49   ` [PATCH 2/4] drm/amdgpu/atif: Send a hotplug event when we get dgpu display request Alex Deucher
  2016-09-14 18:49   ` [PATCH 3/4] drm/radeon/atpx: check for ATIF dGPU wake for display events support Alex Deucher
@ 2016-09-14 18:49   ` Alex Deucher
  2016-09-19 16:00   ` [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support Alex Deucher
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2016-09-14 18:49 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

On PX systems, if the platform supports hotplug events ATIF while the
dGPU is powered down, handle the event and alert userspace.

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

diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
index 31c9a92..6efbd65 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -25,6 +25,7 @@
 #include <linux/acpi.h>
 #include <linux/slab.h>
 #include <linux/power_supply.h>
+#include <linux/pm_runtime.h>
 #include <acpi/video.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
@@ -32,6 +33,12 @@
 #include "radeon_acpi.h"
 #include "atom.h"
 
+#if defined(CONFIG_VGA_SWITCHEROO)
+bool radeon_atpx_dgpu_req_power_for_displays(void);
+#else
+static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
+#endif
+
 #define ACPI_AC_CLASS           "ac_adapter"
 
 extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
@@ -394,6 +401,16 @@ int radeon_atif_handler(struct radeon_device *rdev,
 #endif
 		}
 	}
+	if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
+		if ((rdev->flags & RADEON_IS_PX) &&
+		    radeon_atpx_dgpu_req_power_for_displays()) {
+			pm_runtime_get_sync(rdev->ddev->dev);
+			/* Just fire off a uevent and let userspace tell us what to do */
+			drm_helper_hpd_irq_event(rdev->ddev);
+			pm_runtime_mark_last_busy(rdev->ddev->dev);
+			pm_runtime_put_autosuspend(rdev->ddev->dev);
+		}
+	}
 	/* TODO: check other events */
 
 	/* We've handled the event, stop the notifier chain. The ACPI interface
-- 
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] 6+ messages in thread

* Re: [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support
       [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-09-14 18:49   ` [PATCH 4/4] drm/radeon/atif: Send a hotplug event when we get dgpu display request Alex Deucher
@ 2016-09-19 16:00   ` Alex Deucher
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2016-09-19 16:00 UTC (permalink / raw)
  To: amd-gfx list; +Cc: Alex Deucher

On Wed, Sep 14, 2016 at 2:49 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
> Some ATPX laptops implement special circuitry to generate
> display hotplug events via ACPI when the dGPU is powered off.
> Check if this is supported.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Ping on this series?

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h              | 2 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 9 +++++++++
>  2 files changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 588baaf..681e920 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2463,11 +2463,13 @@ void amdgpu_register_atpx_handler(void);
>  void amdgpu_unregister_atpx_handler(void);
>  bool amdgpu_has_atpx_dgpu_power_cntl(void);
>  bool amdgpu_is_atpx_hybrid(void);
> +bool amdgpu_atpx_dgpu_req_power_for_displays(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; }
>  static inline bool amdgpu_is_atpx_hybrid(void) { return false; }
> +static inline bool amdgpu_atpx_dgpu_req_power_for_displays(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 49de926..550c5ee 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
> @@ -29,6 +29,7 @@ struct amdgpu_atpx {
>         acpi_handle handle;
>         struct amdgpu_atpx_functions functions;
>         bool is_hybrid;
> +       bool dgpu_req_power_for_displays;
>  };
>
>  static struct amdgpu_atpx_priv {
> @@ -73,6 +74,10 @@ bool amdgpu_is_atpx_hybrid(void) {
>         return amdgpu_atpx_priv.atpx.is_hybrid;
>  }
>
> +bool amdgpu_atpx_dgpu_req_power_for_displays(void) {
> +       return amdgpu_atpx_priv.atpx.dgpu_req_power_for_displays;
> +}
> +
>  /**
>   * amdgpu_atpx_call - call an ATPX method
>   *
> @@ -213,6 +218,10 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
>                 atpx->is_hybrid = true;
>         }
>
> +       atpx->dgpu_req_power_for_displays = false;
> +       if (valid_bits & ATPX_DGPU_REQ_POWER_FOR_DISPLAYS)
> +               atpx->dgpu_req_power_for_displays = true;
> +
>         return 0;
>  }
>
> --
> 2.5.5
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 3/4] drm/radeon/atpx: check for ATIF dGPU wake for display events support
       [not found]     ` <1473878944-30900-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-11-23  1:17       ` Peter Wu
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Wu @ 2016-11-23  1:17 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Wed, Sep 14, 2016 at 02:49:03PM -0400, Alex Deucher wrote:
> Some ATPX laptops implement special circuitry to generate
> display hotplug events via ACPI when the dGPU is powered off.
> Check if this is supported.
> 
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

This patch is missing a dgpu_req_power_for_displays, shouldn't you check
for the flag like you did in amdgpu?

Other than that, the patches look good to me.

Peter

> ---
>  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 6de3428..a1321b2 100644
> --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
> +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
> @@ -29,6 +29,7 @@ struct radeon_atpx {
>  	acpi_handle handle;
>  	struct radeon_atpx_functions functions;
>  	bool is_hybrid;
> +	bool dgpu_req_power_for_displays;
>  };
>  
>  static struct radeon_atpx_priv {
> @@ -72,6 +73,10 @@ bool radeon_is_atpx_hybrid(void) {
>  	return radeon_atpx_priv.atpx.is_hybrid;
>  }
>  
> +bool radeon_atpx_dgpu_req_power_for_displays(void) {
> +	return radeon_atpx_priv.atpx.dgpu_req_power_for_displays;
> +}
> +
>  /**
>   * radeon_atpx_call - call an ATPX method
>   *
> -- 
> 2.5.5
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2016-11-23  1:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-14 18:49 [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support Alex Deucher
     [not found] ` <1473878944-30900-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-09-14 18:49   ` [PATCH 2/4] drm/amdgpu/atif: Send a hotplug event when we get dgpu display request Alex Deucher
2016-09-14 18:49   ` [PATCH 3/4] drm/radeon/atpx: check for ATIF dGPU wake for display events support Alex Deucher
     [not found]     ` <1473878944-30900-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-11-23  1:17       ` Peter Wu
2016-09-14 18:49   ` [PATCH 4/4] drm/radeon/atif: Send a hotplug event when we get dgpu display request Alex Deucher
2016-09-19 16:00   ` [PATCH 1/4] drm/amdgpu/atpx: check for ATIF dGPU wake for display events support Alex Deucher

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.