Skip to contentSkip to conversation

drm/amd/powerplay: set dpm_enabled flag but don't enable vcn dpm

PATCH In review Alex Deucher 1 participant 7 messages Jun 17, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 193/459 drm/amd/powerplay: set dpm_enabled flag but don't enable vcn dpm

From: Huang Rui <[email protected]>

This patch sets dpm_enabled flag but don't enable vcn dpm, because vcn dpm doesn't work so far and we needs to enable the sysfs interfaces.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c    | 4 ++--
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 5 +----
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -2
index 6a74f5499ef7..765018322abd 100644
@@ -249,7 +249,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 
 	if (fences == 0) {
 		amdgpu_gfx_off_ctrl(adev, true);
-		if (adev->pm.dpm_enabled)
+		if (adev->asic_type != CHIP_NAVI10 && adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, false);
 		else
 			amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
@@ -266,7 +266,7 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
 
 	if (set_clocks) {
 		amdgpu_gfx_off_ctrl(adev, false);
-		if (adev->pm.dpm_enabled)
+		if (adev->asic_type != CHIP_NAVI10 && adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, true);
 		else
 			amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -4
index 06f5e5ce9db1..652963e52a5a 100644
@@ -865,10 +865,7 @@ static int smu_hw_init(void *handle)
 	if (!smu->pm_enabled)
 		adev->pm.dpm_enabled = false;
 	else
-		adev->pm.dpm_enabled = true;
-	/* TODO: will set dpm_enabled flag while VCN and DAL DPM is workable */
-	if (adev->asic_type != CHIP_NAVI10)
-		adev->pm.dpm_enabled = true;
+		adev->pm.dpm_enabled = true;	/* TODO: will set dpm_enabled flag while VCN and DAL DPM is workable */
 
 	pr_info("SMU is initialized successfully!\n");
 
Signature · 6 lines
2.20.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): 20190617193042.18183-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 194/459 drm/amdgpu/gfx10: fix issues for suspend/resume

From: Jack Xiao <[email protected]>

1). use PREEMPT_QUEUE instead of RESET_QUEUE for gfx ring disablement. 2). Need wait for unmapping queue done before continue execution.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 35 ++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +30 -5
index 9d162d269aca..fae07603e121 100644
@@ -3567,8 +3567,9 @@ static int gfx_v10_0_hw_init(void *handle)
 static int gfx10_0_disable_kgq(struct amdgpu_device *adev)
 {
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
-	struct amdgpu_ring *kiq_ring = &kiq->ring;
-	int i;
+	struct amdgpu_ring *ring, *kiq_ring = &kiq->ring;
+	struct v10_gfx_mqd *mqd;
+	int r, i, j;
 
 	if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)
 		return -EINVAL;
@@ -3577,9 +3578,33 @@ static int gfx10_0_disable_kgq(struct amdgpu_device *adev)
 					adev->gfx.num_gfx_rings))
 		return -ENOMEM;
 
-	for (i = 0; i < adev->gfx.num_gfx_rings; i++)
-		kiq->pmf->kiq_unmap_queues(kiq_ring, &adev->gfx.gfx_ring[i],
-					   RESET_QUEUES, 0, 0);
+	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
+		ring = &adev->gfx.gfx_ring[i];
+
+		r = amdgpu_bo_reserve(ring->mqd_obj, false);
+		if (unlikely(r != 0))
+			return r;
+
+		r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
+		if (!r) {
+			kiq->pmf->kiq_unmap_queues(kiq_ring, ring,
+						   PREEMPT_QUEUES, 0, 0);
+			mqd = ring->mqd_ptr;
+
+			for (j = 0; j < adev->usec_timeout; j++) {
+				if (!mqd->cp_gfx_hqd_active)
+					break;
+				udelay(1);
+			}
+
+			if (j == adev->usec_timeout)
+				DRM_ERROR("failed to wait for gfx inactive\n");
+
+			amdgpu_bo_kunmap(ring->mqd_obj);
+			ring->mqd_ptr = NULL;
+		}
+		amdgpu_bo_unreserve(ring->mqd_obj);
+	}
 
 	return amdgpu_ring_test_ring(kiq_ring);
 }
Signature · 6 lines
2.20.1

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

PATCH 195/459 drm/amdgpu/vcn2: notify SMU power up/down VCN

In reply to a message not in the archive

From: Jack Xiao <[email protected]>

For sw control power gating, it needs notify SMU to power up/down VCN when enter/exit working state.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +7 -0
index 1b9770cb650b..7609e63e59bc 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_vcn.h"
 #include "soc15.h"
 #include "soc15d.h"
+#include "amdgpu_pm.h"
 
 #include "vcn/vcn_2_0_0_offset.h"
 #include "vcn/vcn_2_0_0_sh_mask.h"
@@ -779,6 +780,9 @@ static int vcn_v2_0_start(struct amdgpu_device *adev)
 	uint32_t lmi_swap_cntl;
 	int i, j, r;
 
+	if (adev->pm.dpm_enabled)
+		amdgpu_dpm_enable_uvd(adev, true);
+
 	vcn_v2_0_disable_static_power_gating(adev);
 
 	/* set uvd status busy */
@@ -991,6 +995,9 @@ static int vcn_v2_0_stop(struct amdgpu_device *adev)
 	vcn_v2_0_enable_clock_gating(adev);
 	vcn_v2_0_enable_static_power_gating(adev);
 
+	if (adev->pm.dpm_enabled)
+		amdgpu_dpm_enable_uvd(adev, false);
+
 	return 0;
 }
 
Signature · 6 lines
2.20.1

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

PATCH 196/459 drm/amd/powerplay: enable vcn powergating v2

In reply to a message not in the archive

From: Kenneth Feng <[email protected]>

enable vcn powergating in driver for navi10

v2: set vcn pg bit according to AMD_PG_SUPPORT_VCN flag

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +3 -0
index 6d1b01a5228a..7fc7fd7c2fa0 100644
@@ -275,6 +275,9 @@ navi10_get_allowed_feature_mask(struct smu_context *smu,
 		*(uint64_t *)feature_mask |= FEATURE_MASK(FEATURE_GFX_SS_BIT)
 				| FEATURE_MASK(FEATURE_GFXOFF_BIT);
 
+	if (smu->adev->pg_flags & AMD_PG_SUPPORT_VCN)
+		*(uint64_t *)feature_mask |= FEATURE_MASK(FEATURE_VCN_PG_BIT);
+
 	return 0;
 }
 
Signature · 6 lines
2.20.1

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

PATCH 197/459 drm/amd/powerplay: add new interface for vcn powergating

In reply to a message not in the archive

From: Kenneth Feng <[email protected]>

add new interface for vcn powrergating and vcn dpm as well.

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  4 +++
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    | 28 +++++++++++++++++++
 2 files changed, 32 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
index 5fdf983d6dc6..8ab9d259b453 100644
@@ -224,6 +224,10 @@ enum smu_message_type
 	SMU_MSG_PrepareMp1ForShutdown,
 	SMU_MSG_SetMGpuFanBoostLimitRpm,
 	SMU_MSG_GetAVFSVoltageByDpm,
+	SMU_MSG_PowerUpVcn,
+	SMU_MSG_PowerDownVcn,
+	SMU_MSG_PowerUpJpeg,
+	SMU_MSG_PowerDownJpeg,
 	SMU_MSG_MAX_COUNT,
 };
 
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +28 -0
index 7fc7fd7c2fa0..e0d02a2458c5 100644
@@ -97,6 +97,10 @@ static int navi10_message_map[SMU_MSG_MAX_COUNT] = {
 	MSG_MAP(ExitBaco,			PPSMC_MSG_ExitBaco),
 	MSG_MAP(PrepareMp1ForReset,		PPSMC_MSG_PrepareMp1ForReset),
 	MSG_MAP(PrepareMp1ForShutdown,		PPSMC_MSG_PrepareMp1ForShutdown),
+	MSG_MAP(PowerUpVcn,		PPSMC_MSG_PowerUpVcn),
+	MSG_MAP(PowerDownVcn,		PPSMC_MSG_PowerDownVcn),
+	MSG_MAP(PowerUpJpeg,		PPSMC_MSG_PowerUpJpeg),
+	MSG_MAP(PowerDownJpeg,		PPSMC_MSG_PowerDownJpeg),
 };
 
 static int navi10_clk_map[SMU_CLK_COUNT] = {
@@ -470,6 +474,29 @@ static int navi10_set_default_dpm_table(struct smu_context *smu)
 	return 0;
 }
 
+static int navi10_dpm_set_uvd_enable(struct smu_context *smu, bool enable)
+{
+	int ret = 0;
+	struct smu_power_context *smu_power = &smu->smu_power;
+	struct smu_power_gate *power_gate = &smu_power->power_gate;
+
+	if (enable && power_gate->uvd_gated) {
+		ret = smu_send_smc_msg_with_param(smu, SMU_MSG_PowerUpVcn, 1);
+		if (ret)
+			return ret;
+		power_gate->uvd_gated = false;
+	} else {
+		if (!enable && !power_gate->uvd_gated) {
+			ret = smu_send_smc_msg(smu, SMU_MSG_PowerDownVcn);
+			if (ret)
+				return ret;
+			power_gate->uvd_gated = true;
+		}
+	}
+
+	return 0;
+}
+
 static const struct pptable_funcs navi10_ppt_funcs = {
 	.tables_init = navi10_tables_init,
 	.alloc_dpm_context = navi10_allocate_dpm_context,
@@ -483,6 +510,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {
 	.get_smu_power_index= navi10_get_pwr_src_index,
 	.get_allowed_feature_mask = navi10_get_allowed_feature_mask,
 	.set_default_dpm_table = navi10_set_default_dpm_table,
+	.dpm_set_uvd_enable = navi10_dpm_set_uvd_enable,
 };
 
 void navi10_set_ppt_funcs(struct smu_context *smu)
Signature · 6 lines
2.20.1

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

PATCH 198/459 drm/amdgpu/vcn2: don't access register when power gated

In reply to a message not in the archive

From: Jack Xiao <[email protected]>

It will cause bus hang to access register UVD_STATUS when VCN is in the state of power gated.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c +2 -1
index 7609e63e59bc..d1e90209d088 100644
@@ -277,7 +277,8 @@ static int vcn_v2_0_hw_fini(void *handle)
 	struct amdgpu_ring *ring = &adev->vcn.ring_dec;
 	int i;
 
-	if (RREG32_SOC15(VCN, 0, mmUVD_STATUS))
+	if (adev->vcn.cur_state != AMD_PG_STATE_GATE &&
+	    RREG32_SOC15(VCN, 0, mmUVD_STATUS))
 		vcn_v2_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
 
 	ring->sched.ready = false;
Signature · 6 lines
2.20.1

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

PATCH 199/459 drm/amdgpu: enable vcn dpm scheme for navi

In reply to a message not in the archive

From: Jack Xiao <[email protected]>

On navi1x, vcn dpm scheme was merged into powergating scheme.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -2
index 765018322abd..d0b95e58959a 100644
@@ -249,7 +249,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 
 	if (fences == 0) {
 		amdgpu_gfx_off_ctrl(adev, true);
-		if (adev->asic_type != CHIP_NAVI10 && adev->pm.dpm_enabled)
+		if (adev->asic_type < CHIP_NAVI10 && adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, false);
 		else
 			amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
@@ -266,7 +266,7 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
 
 	if (set_clocks) {
 		amdgpu_gfx_off_ctrl(adev, false);
-		if (adev->asic_type != CHIP_NAVI10 && adev->pm.dpm_enabled)
+		if (adev->asic_type < CHIP_NAVI10 && adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, true);
 		else
 			amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
Signature · 6 lines
2.20.1

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