Skip to contentSkip to conversation

drm/amdgpu: add parse clock gating state

PATCH In review Huang Rui 4 participants 9 messages Jan 9, 2017 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH v4 2/8 drm/amdgpu: add parse clock gating state

---

Changes from V3 -> V4:
- fix some typo

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 33 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  6 ++++++
 2 files changed, 39 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +33 -0
index 1203e9a..dba462f 100644
@@ -34,6 +34,28 @@
 
 static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
 
+static const struct cg_flag_name clocks[] = {
+	{AMD_CG_SUPPORT_GFX_MGCG, "Graphics Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_GFX_MGLS, "Graphics Medium Grain memory Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_CGCG, "Graphics Coarse Grain Clock Gating"},
+	{AMD_CG_SUPPORT_GFX_CGLS, "Graphics Coarse Grain memory Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_CGTS, "Graphics Coarse Grain Tree Shader Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_CGTS_LS, "Graphics Coarse Grain Tree Shader Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_CP_LS, "Graphics Command Processor Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_RLC_LS, "Graphics Run List Controller Light Sleep"},
+	{AMD_CG_SUPPORT_MC_LS, "Memory Controller Light Sleep"},
+	{AMD_CG_SUPPORT_MC_MGCG, "Memory Controller Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_SDMA_LS, "System Direct Memory Access Light Sleep"},
+	{AMD_CG_SUPPORT_SDMA_MGCG, "System Direct Memory Access Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_BIF_LS, "Bus Interface Light Sleep"},
+	{AMD_CG_SUPPORT_UVD_MGCG, "Universal Video Decoder Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_VCE_MGCG, "Video Compression Engine Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_HDP_LS, "Host Data Path Light Sleep"},
+	{AMD_CG_SUPPORT_HDP_MGCG, "Host Data Path Medium Grain Clock Gating"},
+	{AMD_CG_SUPPORT_ROM_MGCG, "Rom Medium Grain Clock Gating"},
+	{0, NULL},
+};
+
 void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 {
 	if (adev->pp_enabled)
@@ -1536,6 +1558,15 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a
 	return 0;
 }
 
+static void amdgpu_parse_cg_state(struct seq_file *m, u32 flags)
+{
+	int i;
+
+	for (i = 0; clocks[i].flag; i++)
+		seq_printf(m, "\t%s: %s\n", clocks[i].name,
+			   (flags & clocks[i].flag) ? "On" : "Off");
+}
+
 static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -1546,6 +1577,8 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
 
 	amdgpu_get_clockgating_state(adev, &flags);
 	seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags);
+	amdgpu_parse_cg_state(m, flags);
+	seq_printf(m, "\n");
 
 	if (!adev->pm.dpm_enabled) {
 		seq_printf(m, "dpm not enabled\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h +6 -0
index 5fd7734..c19c4d1 100644
@@ -24,6 +24,12 @@
 #ifndef __AMDGPU_PM_H__
 #define __AMDGPU_PM_H__
 
+struct cg_flag_name
+{
+	u32 flag;
+	const char *name;
+};
+
 int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);
 void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);
 void amdgpu_pm_print_power_states(struct amdgpu_device *adev);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1483930814-23529-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH v4 7/8 drm/amdgpu: add get clockgating_state method for uvd v5&v6

---

Changes from V3 -> V4:
- use pm mutex to protect UVD clock gating status

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 37 +++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 37 +++++++++++++++++++++++++++++++++--
 3 files changed, 71 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 530549b..31054c7 100644
@@ -1183,6 +1183,7 @@ struct amdgpu_uvd {
 	bool			use_ctx_buf;
 	struct amd_sched_entity entity;
 	uint32_t                srbm_soft_reset;
+	bool			is_powergated;
 };
 
 /*
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +35 -2
index 03a35d9..e647d3e 100644
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
 	 * the smc and the hw blocks
 	 */
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int ret = 0;
 
 	if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
 		return 0;
 
+	mutex_lock(&adev->pm.mutex);
+
 	if (state == AMD_PG_STATE_GATE) {
+		adev->uvd.is_powergated = true;
 		uvd_v5_0_stop(adev);
-		return 0;
 	} else {
-		return uvd_v5_0_start(adev);
+		ret = uvd_v5_0_start(adev);
+		if (ret)
+			goto out;
+		adev->uvd.is_powergated = false;
+	}
+
+out:
+	mutex_unlock(&adev->pm.mutex);
+
+	return ret;
+}
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int data;
+
+	mutex_lock(&adev->pm.mutex);
+
+	if (adev->uvd.is_powergated) {
+		DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+		goto out;
 	}
+
+	/* AMD_CG_SUPPORT_UVD_MGCG */
+	data = RREG32(mmUVD_CGC_CTRL);
+	if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+		*flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+	mutex_unlock(&adev->pm.mutex);
 }
 
 static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
@@ -808,6 +840,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
 	.soft_reset = uvd_v5_0_soft_reset,
 	.set_clockgating_state = uvd_v5_0_set_clockgating_state,
 	.set_powergating_state = uvd_v5_0_set_powergating_state,
+	.get_clockgating_state = uvd_v5_0_get_clockgating_state,
 };
 
 static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +35 -2
index 8779d4b..2585ae9 100644
@@ -987,18 +987,50 @@ static int uvd_v6_0_set_powergating_state(void *handle,
 	 * the smc and the hw blocks
 	 */
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int ret = 0;
 
 	if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
 		return 0;
 
 	WREG32(mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK);
 
+	mutex_lock(&adev->pm.mutex);
+
 	if (state == AMD_PG_STATE_GATE) {
+		adev->uvd.is_powergated = true;
 		uvd_v6_0_stop(adev);
-		return 0;
 	} else {
-		return uvd_v6_0_start(adev);
+		ret = uvd_v6_0_start(adev);
+		if (ret)
+			goto out;
+		adev->uvd.is_powergated = false;
+	}
+
+out:
+	mutex_unlock(&adev->pm.mutex);
+
+	return ret;
+}
+
+static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int data;
+
+	mutex_lock(&adev->pm.mutex);
+
+	if (adev->uvd.is_powergated) {
+		DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+		goto out;
 	}
+
+	/* AMD_CG_SUPPORT_UVD_MGCG */
+	data = RREG32(mmUVD_CGC_CTRL);
+	if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+		*flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+	mutex_unlock(&adev->pm.mutex);
 }
 
 static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
@@ -1019,6 +1051,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
 	.post_soft_reset = uvd_v6_0_post_soft_reset,
 	.set_clockgating_state = uvd_v6_0_set_clockgating_state,
 	.set_powergating_state = uvd_v6_0_set_powergating_state,
+	.get_clockgating_state = uvd_v6_0_get_clockgating_state,
 };
 
 static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = {
Signature · 6 lines
2.7.4

_______________________________________________
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): 1483930814-23529-2-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Am 09.01.2017 um 04:00 schrieb Huang Rui:

Quoted 29 lines

---

Changes from V3 -> V4:
- use pm mutex to protect UVD clock gating status

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
  drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 37 +++++++++++++++++++++++++++++++++--
  drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 37 +++++++++++++++++++++++++++++++++--
  3 files changed, 71 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 530549b..31054c7 100644
@@ -1183,6 +1183,7 @@ struct amdgpu_uvd {
  	bool			use_ctx_buf;
  	struct amd_sched_entity entity;
  	uint32_t                srbm_soft_reset;
+	bool			is_powergated;
  };
 
  /*
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +0 -0
index 03a35d9..e647d3e 100644

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 789

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +2 -0
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
  	 * the smc and the hw blocks
  	 */
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int ret = 0;
 
  	if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
  		return 0;
 
+	mutex_lock(&adev->pm.mutex);

Might be that I'm wrong, but didn't Tom said the mutex is taken anyway when this function is called?

If that's true we would certainly run into problem when we try to acquire it again.

Christian.

Quoted 107 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +33 -2
+
  	if (state == AMD_PG_STATE_GATE) {
+		adev->uvd.is_powergated = true;
  		uvd_v5_0_stop(adev);
-		return 0;
  	} else {
-		return uvd_v5_0_start(adev);
+		ret = uvd_v5_0_start(adev);
+		if (ret)
+			goto out;
+		adev->uvd.is_powergated = false;
+	}
+
+out:
+	mutex_unlock(&adev->pm.mutex);
+
+	return ret;
+}
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int data;
+
+	mutex_lock(&adev->pm.mutex);
+
+	if (adev->uvd.is_powergated) {
+		DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+		goto out;
  	}
+
+	/* AMD_CG_SUPPORT_UVD_MGCG */
+	data = RREG32(mmUVD_CGC_CTRL);
+	if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+		*flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+	mutex_unlock(&adev->pm.mutex);
  }
 
  static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
@@ -808,6 +840,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
  	.soft_reset = uvd_v5_0_soft_reset,
  	.set_clockgating_state = uvd_v5_0_set_clockgating_state,
  	.set_powergating_state = uvd_v5_0_set_powergating_state,
+	.get_clockgating_state = uvd_v5_0_get_clockgating_state,
  };
 
  static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +34 -2
index 8779d4b..2585ae9 100644
@@ -987,18 +987,50 @@ static int uvd_v6_0_set_powergating_state(void *handle,
  	 * the smc and the hw blocks
  	 */
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int ret = 0;
 
  	if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
  		return 0;
 
  	WREG32(mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK);
 
+	mutex_lock(&adev->pm.mutex);
+
  	if (state == AMD_PG_STATE_GATE) {
+		adev->uvd.is_powergated = true;
  		uvd_v6_0_stop(adev);
-		return 0;
  	} else {
-		return uvd_v6_0_start(adev);
+		ret = uvd_v6_0_start(adev);
+		if (ret)
+			goto out;
+		adev->uvd.is_powergated = false;
+	}
+
+out:
+	mutex_unlock(&adev->pm.mutex);
+
+	return ret;
+}
+
+static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int data;
+
+	mutex_lock(&adev->pm.mutex);
+
+	if (adev->uvd.is_powergated) {
+		DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+		goto out;
  	}
+
+	/* AMD_CG_SUPPORT_UVD_MGCG */
+	data = RREG32(mmUVD_CGC_CTRL);
+	if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+		*flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+	mutex_unlock(&adev->pm.mutex);
  }
 
  static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {

drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { · line 1057

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +1 -0
@@ -1019,6 +1051,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
  	.post_soft_reset = uvd_v6_0_post_soft_reset,
  	.set_clockgating_state = uvd_v6_0_set_clockgating_state,
  	.set_powergating_state = uvd_v6_0_set_powergating_state,
+	.get_clockgating_state = uvd_v6_0_get_clockgating_state,
  };
 
  static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = {

_______________________________________________
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): 364cc068-e347-5f77-b4ff-414f8e8b4fdb-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Yup it's held by both amdgpu_dpm_enable_uvd() and amdgpu_dpm_enable_vce()

Tom

________________________________
From: Koenig, Christian
Sent: Monday, January 9, 2017 05:32
To: Huang, Ray; Deucher, Alexander; [email protected]; StDenis, Tom
Cc: Zhu, Rex; Mao, David; Fu, Ping; Zhang, Hawking; Kuehling, Felix
Subject: Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Am 09.01.2017 um 04:00 schrieb Huang Rui:

Quoted 29 lines

---

Changes from V3 -> V4:
- use pm mutex to protect UVD clock gating status

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
  drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 37 +++++++++++++++++++++++++++++++++--
  drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 37 +++++++++++++++++++++++++++++++++--
  3 files changed, 71 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 530549b..31054c7 100644
@@ -1183,6 +1183,7 @@ struct amdgpu_uvd {
       bool                    use_ctx_buf;
       struct amd_sched_entity entity;
       uint32_t                srbm_soft_reset;
+     bool                    is_powergated;
  };
 
  /*
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +0 -0
index 03a35d9..e647d3e 100644

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 789

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +2 -0
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
        * the smc and the hw blocks
        */
       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int ret = 0;
 
       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
               return 0;
 
+     mutex_lock(&adev->pm.mutex);

Might be that I'm wrong, but didn't Tom said the mutex is taken anyway when this function is called?

If that's true we would certainly run into problem when we try to acquire it again.

Christian.

Quoted 107 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +33 -2
+
       if (state == AMD_PG_STATE_GATE) {
+             adev->uvd.is_powergated = true;
               uvd_v5_0_stop(adev);
-             return 0;
       } else {
-             return uvd_v5_0_start(adev);
+             ret = uvd_v5_0_start(adev);
+             if (ret)
+                     goto out;
+             adev->uvd.is_powergated = false;
+     }
+
+out:
+     mutex_unlock(&adev->pm.mutex);
+
+     return ret;
+}
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int data;
+
+     mutex_lock(&adev->pm.mutex);
+
+     if (adev->uvd.is_powergated) {
+             DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+             goto out;
       }
+
+     /* AMD_CG_SUPPORT_UVD_MGCG */
+     data = RREG32(mmUVD_CGC_CTRL);
+     if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+             *flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+     mutex_unlock(&adev->pm.mutex);
  }
 
  static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
@@ -808,6 +840,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = {
       .soft_reset = uvd_v5_0_soft_reset,
       .set_clockgating_state = uvd_v5_0_set_clockgating_state,
       .set_powergating_state = uvd_v5_0_set_powergating_state,
+     .get_clockgating_state = uvd_v5_0_get_clockgating_state,
  };
 
  static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +34 -2
index 8779d4b..2585ae9 100644
@@ -987,18 +987,50 @@ static int uvd_v6_0_set_powergating_state(void *handle,
        * the smc and the hw blocks
        */
       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int ret = 0;
 
       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
               return 0;
 
       WREG32(mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK);
 
+     mutex_lock(&adev->pm.mutex);
+
       if (state == AMD_PG_STATE_GATE) {
+             adev->uvd.is_powergated = true;
               uvd_v6_0_stop(adev);
-             return 0;
       } else {
-             return uvd_v6_0_start(adev);
+             ret = uvd_v6_0_start(adev);
+             if (ret)
+                     goto out;
+             adev->uvd.is_powergated = false;
+     }
+
+out:
+     mutex_unlock(&adev->pm.mutex);
+
+     return ret;
+}
+
+static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags)
+{
+     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int data;
+
+     mutex_lock(&adev->pm.mutex);
+
+     if (adev->uvd.is_powergated) {
+             DRM_INFO("Cannot get clockgating state when UVD is powergated.\n");
+             goto out;
       }
+
+     /* AMD_CG_SUPPORT_UVD_MGCG */
+     data = RREG32(mmUVD_CGC_CTRL);
+     if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK)
+             *flags |= AMD_CG_SUPPORT_UVD_MGCG;
+
+out:
+     mutex_unlock(&adev->pm.mutex);
  }
 
  static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {

drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { · line 1057

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +1 -0
@@ -1019,6 +1051,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
       .post_soft_reset = uvd_v6_0_post_soft_reset,
       .set_clockgating_state = uvd_v6_0_set_clockgating_state,
       .set_powergating_state = uvd_v6_0_set_powergating_state,
+     .get_clockgating_state = uvd_v6_0_get_clockgating_state,
  };
 
  static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = {

_______________________________________________
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): CY4PR12MB176846FDA72EF232B6825609F7640-rpdhrqHFk06yjjPBNVDk/[email protected]

author
#8 lore raw

Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Quoted 4 lines · Tom

Yup it's held by both amdgpu_dpm_enable_uvd() and amdgpu_dpm_enable_vce()

Tom

<snip>

Quoted 14 lines

drivers/gpu/drm/amd/

Quoted 1 line
drivers/gpu/drm/amd/ renamed from drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +0 -0

amdgpu/uvd_v5_0.c

Quoted 12 lines

index 03a35d9..e647d3e 100644

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
        * the smc and the hw blocks
        */
       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int ret = 0;
 
       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
               return 0;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 789

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
+     mutex_lock(&adev->pm.mutex);

Might be that I'm wrong, but didn't Tom said the mutex is taken anyway when this function is called?

If that's true we would certainly run into problem when we try to acquire it again.

OK, I see. Actually, pm.mutex is already held on upper layer call (amdgpu_dpm_enable_uvd). So we should not hold it again here.

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 813

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +8 -0
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int data;
+
+     mutex_lock(&adev->pm.mutex);
+

We just need keep pm.mutex here in set_clockgating_state, that's enough.

Christian, Tom, am I right?

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

#9 lore raw

Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Am 09.01.2017 um 15:46 schrieb Huang Rui:

Quoted 41 lines · Tom
Quoted 4 lines

Yup it's held by both amdgpu_dpm_enable_uvd() and amdgpu_dpm_enable_vce()

Tom

<snip>

Quoted 14 lines

drivers/gpu/drm/amd/

Quoted 1 line
drivers/gpu/drm/amd/ renamed from drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +0 -0

amdgpu/uvd_v5_0.c

Quoted 12 lines

index 03a35d9..e647d3e 100644

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
         * the smc and the hw blocks
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int ret = 0;
 
        if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
                return 0;
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 789

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
+     mutex_lock(&adev->pm.mutex);

Might be that I'm wrong, but didn't Tom said the mutex is taken anyway when this function is called?

If that's true we would certainly run into problem when we try to acquire it again.

OK, I see. Actually, pm.mutex is already held on upper layer call (amdgpu_dpm_enable_uvd). So we should not hold it again here.

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 797

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +8 -0
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int data;
+
+     mutex_lock(&adev->pm.mutex);
+

We just need keep pm.mutex here in set_clockgating_state, that's enough.

Quoted 1 line

Christian, Tom, am I right?

Yes, I think so.

Christian.

Quoted 3 lines

Thanks,
Rui

_______________________________________________
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): 523a8df8-2573-0c56-e6c7-5ac74f77f1f3-5C7GfCeVMHo@public.gmane.org

#11 lore raw

Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Yes, holding pm.mutex will prevent PP/DPM from entering/leaving PG states and is used as a means to probe power/clock related signals reliably (except for VCE clock signals which aren't part of an AON tile).

You just can't take it from a "set" state function since the higher up API will take it.

Tom

________________________________
From: Koenig, Christian
Sent: Monday, January 9, 2017 09:45
To: Huang, Ray; StDenis, Tom
Cc: Deucher, Alexander; [email protected]; Zhu, Rex; Mao, David; Fu, Ping; Zhang, Hawking; Kuehling, Felix
Subject: Re: [PART1 PATCH v4 7/8] drm/amdgpu: add get clockgating_state method for uvd v5&v6

Am 09.01.2017 um 15:46 schrieb Huang Rui:

Quoted 41 lines · Tom
Quoted 4 lines

Yup it's held by both amdgpu_dpm_enable_uvd() and amdgpu_dpm_enable_vce()

Tom

<snip>

Quoted 14 lines

drivers/gpu/drm/amd/

Quoted 1 line
drivers/gpu/drm/amd/ renamed from drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +0 -0

amdgpu/uvd_v5_0.c

Quoted 12 lines

index 03a35d9..e647d3e 100644

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
@@ -781,16 +781,48 @@ static int uvd_v5_0_set_powergating_state(void *handle,
         * the smc and the hw blocks
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int ret = 0;
 
        if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
                return 0;
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 789

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +1 -0
+     mutex_lock(&adev->pm.mutex);

Might be that I'm wrong, but didn't Tom said the mutex is taken anyway when this function is called?

If that's true we would certainly run into problem when we try to acquire it again.

OK, I see. Actually, pm.mutex is already held on upper layer call (amdgpu_dpm_enable_uvd). So we should not hold it again here.

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c static int uvd_v5_0_set_powergating_state(void *handle, · line 797

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +8 -0
+
+static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags)
+{
+     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     int data;
+
+     mutex_lock(&adev->pm.mutex);
+

We just need keep pm.mutex here in set_clockgating_state, that's enough.

Quoted 1 line

Christian, Tom, am I right?

Yes, I think so.

Christian.

Quoted 3 lines

Thanks,
Rui

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

author
#12 lore raw

PATCH v4 8/8 drm/amdgpu: add get clockgating_state method for vce v3

In reply to a message not in the archive

---

Changes from V3 -> V4:
- use pm mutex to protect VCE clock gating status

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 44 +++++++++++++++++++++++++++++++----
 2 files changed, 41 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 31054c7..3c52b81 100644
@@ -1212,6 +1212,7 @@ struct amdgpu_vce {
 	struct amd_sched_entity	entity;
 	uint32_t                srbm_soft_reset;
 	unsigned		num_rings;
+	bool			is_powergated;
 };
 
 /*
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +40 -4

61 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by Alex Deucher
#13 lore raw
In reply to a message not in the archive
Quoted 59 lines

-----Original Message-----
From: Huang Rui [mailto:[email protected]]
Sent: Sunday, January 08, 2017 10:00 PM
To: Deucher, Alexander; [email protected]; Koenig, Christian; StDenis, Tom
Cc: Zhu, Rex; Mao, David; Fu, Ping; Zhang, Hawking; Kuehling, Felix; Huang, Ray; William Lewis
Subject: [PART1 PATCH v4 2/8] drm/amdgpu: add parse clock gating state

---

Changes from V3 -> V4:
- fix some typo

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 33
+++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  6 ++++++
 2 files changed, 39 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +5 -0
index 1203e9a..dba462f 100644
@@ -34,6 +34,28 @@
 
 static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
 
+static const struct cg_flag_name clocks[] = {
+	{AMD_CG_SUPPORT_GFX_MGCG, "Graphics Medium Grain Clock
 Gating"},
+	{AMD_CG_SUPPORT_GFX_MGLS, "Graphics Medium Grain memory
 Light Sleep"},
+	{AMD_CG_SUPPORT_GFX_CGCG, "Graphics Coarse Grain Clock
 Gating"},
+	{AMD_CG_SUPPORT_GFX_CGLS, "Graphics Coarse Grain memory

Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_GFX_CGTS, "Graphics Coarse Grain Tree

Shader Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_GFX_CGTS_LS, "Graphics Coarse Grain Tree

Shader Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_GFX_CP_LS, "Graphics Command Processor

Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_GFX_RLC_LS, "Graphics Run List Controller

Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
+	{AMD_CG_SUPPORT_MC_LS, "Memory Controller Light Sleep"},
+	{AMD_CG_SUPPORT_MC_MGCG, "Memory Controller Medium

Grain Clock Gating"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_SDMA_LS, "System Direct Memory Access

Light Sleep"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_SDMA_MGCG, "System Direct Memory Access

Medium Grain Clock Gating"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
+	{AMD_CG_SUPPORT_BIF_LS, "Bus Interface Light Sleep"},
+	{AMD_CG_SUPPORT_UVD_MGCG, "Universal Video Decoder
Quoted 1 line

Medium Grain Clock Gating"},

Universal -> Unified
With that fixed:

Quoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_VCE_MGCG, "Video Compression Engine

Medium Grain Clock Gating"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
+	{AMD_CG_SUPPORT_HDP_LS, "Host Data Path Light Sleep"},
+	{AMD_CG_SUPPORT_HDP_MGCG, "Host Data Path Medium Grain

Clock Gating"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -0
+	{AMD_CG_SUPPORT_ROM_MGCG, "Rom Medium Grain Clock

Gating"},

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3 -0
+	{0, NULL},
+};
+
 void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 {
 	if (adev->pp_enabled)
@@ -1536,6 +1558,15 @@ static int amdgpu_debugfs_pm_info_pp(struct

seq_file *m, struct amdgpu_device *a

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +9 -0
 	return 0;
 }
 
+static void amdgpu_parse_cg_state(struct seq_file *m, u32 flags)
+{
+	int i;
+
+	for (i = 0; clocks[i].flag; i++)
+		seq_printf(m, "\t%s: %s\n", clocks[i].name,
+			   (flags & clocks[i].flag) ? "On" : "Off");
+}
+
 static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m-
Quoted 1 line

private;

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
@@ -1546,6 +1577,8 @@ static int amdgpu_debugfs_pm_info(struct seq_file
 *m, void *data)
 
 	amdgpu_get_clockgating_state(adev, &flags);
 	seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags);
+	amdgpu_parse_cg_state(m, flags);
+	seq_printf(m, "\n");
 
 	if (!adev->pm.dpm_enabled) {
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0 -0
 		seq_printf(m, "dpm not enabled\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h +6 -1
index 5fd7734..c19c4d1 100644
@@ -24,6 +24,12 @@
 #ifndef __AMDGPU_PM_H__
 #define __AMDGPU_PM_H__
 
+struct cg_flag_name
+{
+	u32 flag;
+	const char *name;
+};
+
 int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);
 void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);
 void amdgpu_pm_print_power_states(struct amdgpu_device *adev);
--
Quoted 1 line

2.7.4

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