Skip to contentSkip to conversation

drm/amdgpu: Change PG enable sequence

PATCH In review Rex Zhu 2 participants 2 messages Jun 5, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/2 drm/amdgpu: Change PG enable sequence

Enable PG state after CG enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 +++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  4 ----
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  5 -----
 3 files changed, 29 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +29 -0
index 7a085f6..4003038 100644
@@ -1734,6 +1734,34 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 	return 0;
 }
 
+static int amdgpu_device_ip_late_set_pg_state(struct amdgpu_device *adev)
+{
+	int i = 0;
+
+	if (amdgpu_emu_mode == 1)
+		return 0;
+
+	for (i = 0; i < adev->num_ip_blocks; i++) {
+		if (!adev->ip_blocks[i].status.valid)
+			continue;
+		/* skip CG for VCE/UVD, it's handled specially */
+		if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD &&
+		    adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE &&
+		    adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCN &&
+		    adev->ip_blocks[i].version->funcs->set_powergating_state) {
+			/* enable powergating to save power */
+			r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev,
+										     AMD_PG_STATE_GATE);
+			if (r) {
+				DRM_ERROR("set_powergating_state(gate) of IP block <%s> failed %d\n",
+					  adev->ip_blocks[i].version->funcs->name, r);
+				return r;
+			}
+		}
+	}
+	return 0;
+}
+
 /**
  * amdgpu_device_ip_late_init - run late init for hardware IPs
  *
@@ -1891,6 +1919,7 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work)
 	struct amdgpu_device *adev =
 		container_of(work, struct amdgpu_device, late_init_work.work);
 	amdgpu_device_ip_late_set_cg_state(adev);
+	amdgpu_device_ip_late_set_pg_state(adev);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -4
index 50ba9c9..37fc55e 100644
@@ -5542,10 +5542,6 @@ static int gfx_v8_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	amdgpu_device_ip_set_powergating_state(adev,
-					       AMD_IP_BLOCK_TYPE_GFX,
-					       AMD_PG_STATE_GATE);
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index c188616..c382969 100644
@@ -3406,11 +3406,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1528185759-1629-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 1 line

/* skip CG for VCE/UVD, it's handled specially */

The comment should be fixed as this is for pg not cg.
With that fixed, the patch is Reviewed-by: Evan Quan <[email protected]>

Quoted 114 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Rex Zhu
Sent: Tuesday, June 05, 2018 4:03 PM
To: [email protected]
Cc: Zhu, Rex <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Change PG enable sequence

Enable PG state after CG enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29
+++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  4 ----
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  5 -----
 3 files changed, 29 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index 7a085f6..4003038 100644
@@ -1734,6 +1734,34 @@ static int
 amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 	return 0;
 }
 
+static int amdgpu_device_ip_late_set_pg_state(struct amdgpu_device
+*adev) {
+	int i = 0;
+
+	if (amdgpu_emu_mode == 1)
+		return 0;
+
+	for (i = 0; i < adev->num_ip_blocks; i++) {
+		if (!adev->ip_blocks[i].status.valid)
+			continue;
+		/* skip CG for VCE/UVD, it's handled specially */
+		if (adev->ip_blocks[i].version->type !=

AMD_IP_BLOCK_TYPE_UVD &&

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+		    adev->ip_blocks[i].version->type !=

AMD_IP_BLOCK_TYPE_VCE &&

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+		    adev->ip_blocks[i].version->type !=

AMD_IP_BLOCK_TYPE_VCN &&

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+		    adev->ip_blocks[i].version->funcs-
Quoted 1 line

set_powergating_state) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+			/* enable powergating to save power */
+			r = adev->ip_blocks[i].version->funcs-
Quoted 1 line

set_powergating_state((void *)adev,

+

	     AMD_PG_STATE_GATE);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+			if (r) {
+				DRM_ERROR("set_powergating_state(gate)

of IP block <%s> failed %d\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+					  adev->ip_blocks[i].version->funcs-
Quoted 1 line

name, r);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
+				return r;
+			}
+		}
+	}
+	return 0;
+}
+
 /**
  * amdgpu_device_ip_late_init - run late init for hardware IPs
  *
@@ -1891,6 +1919,7 @@ static void
 amdgpu_device_ip_late_init_func_handler(struct work_struct *work)
 	struct amdgpu_device *adev =
 		container_of(work, struct amdgpu_device,
 late_init_work.work);
 	amdgpu_device_ip_late_set_cg_state(adev);
+	amdgpu_device_ip_late_set_pg_state(adev);
 }

/**

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -4
index 50ba9c9..37fc55e 100644
@@ -5542,10 +5542,6 @@ static int gfx_v8_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	amdgpu_device_ip_set_powergating_state(adev,
-					       AMD_IP_BLOCK_TYPE_GFX,
-					       AMD_PG_STATE_GATE);
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -6
index c188616..c382969 100644
@@ -3406,11 +3406,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev,
 AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx