Skip to contentSkip to conversation

drm/amdgpu: expand runpm parameter

PATCH In review Alex Deucher 3 participants 3 messages Jul 12, 2023 – Aug 10, 2023

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: expand runpm parameter

Allow the user to specify -2 as auto enabled with displays.

By default we don't enter runtime suspend when there are displays attached because it does not work well in some desktop environments due to the driver sending hotplug events on resume in case any new displays were attached while the GPU was powered down. Some users still want this functionality though, so this lets you enable it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 37 +++++++++++++------------
 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +20 -17
index 721f3c6160bcb..33e370d998a87 100644
@@ -350,8 +350,9 @@ module_param_named(aspm, amdgpu_aspm, int, 0444);
  * Override for runtime power management control for dGPUs. The amdgpu driver can dynamically power down
  * the dGPUs when they are idle if supported. The default is -1 (auto enable).
  * Setting the value to 0 disables this functionality.
+ * Setting the value to -2 is auto enabled with power down when displays are attached.
  */
-MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto)");
+MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto, -2 = autowith displays)");
 module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
 
 /**
@@ -2657,24 +2658,26 @@ static int amdgpu_runtime_idle_check_display(struct device *dev)
 		struct drm_connector_list_iter iter;
 		int ret = 0;
 
-		/* XXX: Return busy if any displays are connected to avoid
-		 * possible display wakeups after runtime resume due to
-		 * hotplug events in case any displays were connected while
-		 * the GPU was in suspend.  Remove this once that is fixed.
-		 */
-		mutex_lock(&drm_dev->mode_config.mutex);
-		drm_connector_list_iter_begin(drm_dev, &iter);
-		drm_for_each_connector_iter(list_connector, &iter) {
-			if (list_connector->status == connector_status_connected) {
-				ret = -EBUSY;
-				break;
+		if (amdgpu_runtime_pm != -2) {
+			/* XXX: Return busy if any displays are connected to avoid
+			 * possible display wakeups after runtime resume due to
+			 * hotplug events in case any displays were connected while
+			 * the GPU was in suspend.  Remove this once that is fixed.
+			 */
+			mutex_lock(&drm_dev->mode_config.mutex);
+			drm_connector_list_iter_begin(drm_dev, &iter);
+			drm_for_each_connector_iter(list_connector, &iter) {
+				if (list_connector->status == connector_status_connected) {
+					ret = -EBUSY;
+					break;
+				}
 			}
-		}
-		drm_connector_list_iter_end(&iter);
-		mutex_unlock(&drm_dev->mode_config.mutex);
+			drm_connector_list_iter_end(&iter);
+			mutex_unlock(&drm_dev->mode_config.mutex);
 
-		if (ret)
-			return ret;
+			if (ret)
+				return ret;
+		}
 
 		if (adev->dc_enabled) {
 			struct drm_crtc *crtc;
Signature · 1 line
2.41.0
#1 lore raw

Ping?

Quoted 77 lines · Alex Deucher

Allow the user to specify -2 as auto enabled with displays.

By default we don't enter runtime suspend when there are displays attached because it does not work well in some desktop environments due to the driver sending hotplug events on resume in case any new displays were attached while the GPU was powered down. Some users still want this functionality though, so this lets you enable it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 37 +++++++++++++------------
 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +20 -18
index 721f3c6160bcb..33e370d998a87 100644
@@ -350,8 +350,9 @@ module_param_named(aspm, amdgpu_aspm, int, 0444);
  * Override for runtime power management control for dGPUs. The amdgpu driver can dynamically power down
  * the dGPUs when they are idle if supported. The default is -1 (auto enable).
  * Setting the value to 0 disables this functionality.
+ * Setting the value to -2 is auto enabled with power down when displays are attached.
  */
-MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto)");
+MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto, -2 = autowith displays)");
 module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
 
 /**
@@ -2657,24 +2658,26 @@ static int amdgpu_runtime_idle_check_display(struct device *dev)
                struct drm_connector_list_iter iter;
                int ret = 0;
 
-               /* XXX: Return busy if any displays are connected to avoid
-                * possible display wakeups after runtime resume due to
-                * hotplug events in case any displays were connected while
-                * the GPU was in suspend.  Remove this once that is fixed.
-                */
-               mutex_lock(&drm_dev->mode_config.mutex);
-               drm_connector_list_iter_begin(drm_dev, &iter);
-               drm_for_each_connector_iter(list_connector, &iter) {
-                       if (list_connector->status == connector_status_connected) {
-                               ret = -EBUSY;
-                               break;
+               if (amdgpu_runtime_pm != -2) {
+                       /* XXX: Return busy if any displays are connected to avoid
+                        * possible display wakeups after runtime resume due to
+                        * hotplug events in case any displays were connected while
+                        * the GPU was in suspend.  Remove this once that is fixed.
+                        */
+                       mutex_lock(&drm_dev->mode_config.mutex);
+                       drm_connector_list_iter_begin(drm_dev, &iter);
+                       drm_for_each_connector_iter(list_connector, &iter) {
+                               if (list_connector->status == connector_status_connected) {
+                                       ret = -EBUSY;
+                                       break;
+                               }
                        }
-               }
-               drm_connector_list_iter_end(&iter);
-               mutex_unlock(&drm_dev->mode_config.mutex);
+                       drm_connector_list_iter_end(&iter);
+                       mutex_unlock(&drm_dev->mode_config.mutex);
 
-               if (ret)
-                       return ret;
+                       if (ret)
+                               return ret;
+               }
 
                if (adev->dc_enabled) {
                        struct drm_crtc *crtc;
--

2.41.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Deucher

[Public]

Regards,
Guchun

Quoted 98 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 12, 2023 11:53 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: expand runpm parameter

Allow the user to specify -2 as auto enabled with displays.

By default we don't enter runtime suspend when there are displays attached because it does not work well in some desktop environments due to the driver sending hotplug events on resume in case any new displays were attached while the GPU was powered down. Some users still want this functionality though, so this lets you enable it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 37 +++++++++++++-----------
(quoted diff) +0 -1
-
 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
index 721f3c6160bcb..33e370d998a87 100644
@@ -350,8 +350,9 @@ module_param_named(aspm, amdgpu_aspm, int,
 0444);
  * Override for runtime power management control for dGPUs. The amdgpu

driver can dynamically power down
* the dGPUs when they are idle if supported. The default is -1 (auto enable).
* Setting the value to 0 disables this functionality.
+ * Setting the value to -2 is auto enabled with power down when displays are attached.
*/
-MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto)"); +MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1
+= force enable with BACO, 0 = disable, -1 = auto, -2 = autowith

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -11
+displays)");
 module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
 
 /**
@@ -2657,24 +2658,26 @@ static int
 amdgpu_runtime_idle_check_display(struct device *dev)
              struct drm_connector_list_iter iter;
              int ret = 0;
 
-             /* XXX: Return busy if any displays are connected to avoid
-              * possible display wakeups after runtime resume due to
-              * hotplug events in case any displays were connected while
-              * the GPU was in suspend.  Remove this once that is fixed.
-              */
-             mutex_lock(&drm_dev->mode_config.mutex);
-             drm_connector_list_iter_begin(drm_dev, &iter);
-             drm_for_each_connector_iter(list_connector, &iter) {
-                     if (list_connector->status ==
 connector_status_connected) {
-                             ret = -EBUSY;
-                             break;
+             if (amdgpu_runtime_pm != -2) {
+                     /* XXX: Return busy if any displays are connected to

avoid
+ * possible display wakeups after runtime resume
due to
+ * hotplug events in case any displays were
connected while
+ * the GPU was in suspend. Remove this once that is
fixed.

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
+                      */
+                     mutex_lock(&drm_dev->mode_config.mutex);
+                     drm_connector_list_iter_begin(drm_dev, &iter);
+                     drm_for_each_connector_iter(list_connector, &iter) {
+                             if (list_connector->status ==

connector_status_connected) {

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8 -6
+                                     ret = -EBUSY;
+                                     break;
+                             }
                      }
-             }
-             drm_connector_list_iter_end(&iter);
-             mutex_unlock(&drm_dev->mode_config.mutex);
+                     drm_connector_list_iter_end(&iter);
+                     mutex_unlock(&drm_dev->mode_config.mutex);
 
-             if (ret)
-                     return ret;
+                     if (ret)
+                             return ret;
+             }
 
              if (adev->dc_enabled) {
                      struct drm_crtc *crtc;
--

2.41.0