dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Sonny Jiang <sonny.jiang@amd.com>
Subject: [PATCH 83/88] drm/amdgpu: enable uvd dpm and powergating
Date: Tue, 26 May 2015 23:20:22 -0400	[thread overview]
Message-ID: <1432696827-3752-53-git-send-email-alexander.deucher@amd.com> (raw)
In-Reply-To: <1432696827-3752-1-git-send-email-alexander.deucher@amd.com>

From: Sonny Jiang <sonny.jiang@amd.com>

Enable UVD dpm (dynamic power management) and powergating.  UVD dpm dynamically scales the UVD
clocks on demand.  Powergating turns off the power to the block when it's not in use.

Signed-off-by: Sonny Jiang <sonny.jiang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/cz_dpm.c | 90 ++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/cz_dpm.h |  2 +
 drivers/gpu/drm/amd/amdgpu/vi.c     |  2 +-
 3 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
index adf4dbc..2649b50 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
@@ -42,6 +42,8 @@
 #include "bif/bif_5_1_d.h"
 #include "gfx_v8_0.h"
 
+static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate);
+
 static struct cz_ps *cz_get_ps(struct amdgpu_ps *rps)
 {
 	struct cz_ps *ps = rps->ps_priv;
@@ -474,6 +476,7 @@ static int cz_dpm_init(struct amdgpu_device *adev)
 		return ret;
 
 	pi->dpm_enabled = true;
+	pi->uvd_dynamic_pg = false;
 
 	return 0;
 }
@@ -546,6 +549,15 @@ static int cz_dpm_early_init(struct amdgpu_device *adev)
 	return 0;
 }
 
+
+static int cz_dpm_late_init(struct amdgpu_device *adev)
+{
+	/* powerdown unused blocks for now */
+	cz_dpm_powergate_uvd(adev, true);
+
+	return 0;
+}
+
 static int cz_dpm_sw_init(struct amdgpu_device *adev)
 {
 	int ret = 0;
@@ -1260,6 +1272,9 @@ static int cz_dpm_disable(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
+	/* powerup blocks */
+	cz_dpm_powergate_uvd(adev, false);
+
 	cz_clear_voting_clients(adev);
 	cz_stop_dpm(adev);
 	cz_update_current_ps(adev, adev->pm.dpm.boot_ps);
@@ -1677,9 +1692,80 @@ static uint32_t cz_dpm_get_mclk(struct amdgpu_device *adev, bool low)
 	return pi->sys_info.bootup_uma_clk;
 }
 
+static int cz_enable_uvd_dpm(struct amdgpu_device *adev, bool enable)
+{
+	struct cz_power_info *pi = cz_get_pi(adev);
+	int ret = 0;
+
+	if (enable && pi->caps_uvd_dpm ) {
+		pi->dpm_flags |= DPMFlags_UVD_Enabled;
+		DRM_DEBUG("UVD DPM Enabled.\n");
+
+		ret = cz_send_msg_to_smc_with_parameter(adev,
+			PPSMC_MSG_EnableAllSmuFeatures, UVD_DPM_MASK);
+	} else {
+		pi->dpm_flags &= ~DPMFlags_UVD_Enabled;
+		DRM_DEBUG("UVD DPM Stopped\n");
+
+		ret = cz_send_msg_to_smc_with_parameter(adev,
+			PPSMC_MSG_DisableAllSmuFeatures, UVD_DPM_MASK);
+	}
+
+	return ret;
+}
+
+static int cz_update_uvd_dpm(struct amdgpu_device *adev, bool gate)
+{
+	return cz_enable_uvd_dpm(adev, !gate);
+}
+
+
+static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate)
+{
+	struct cz_power_info *pi = cz_get_pi(adev);
+	int ret;
+
+	if (pi->uvd_power_gated == gate)
+		return;
+
+	pi->uvd_power_gated = gate;
+
+	if (gate) {
+		if (pi->caps_uvd_pg) {
+			/* disable clockgating so we can properly shut down the block */
+			ret = amdgpu_set_clockgating_state(adev, AMDGPU_IP_BLOCK_TYPE_UVD,
+							    AMDGPU_CG_STATE_UNGATE);
+			/* shutdown the UVD block */
+			ret = amdgpu_set_powergating_state(adev, AMDGPU_IP_BLOCK_TYPE_UVD,
+							    AMDGPU_PG_STATE_GATE);
+			/* XXX: check for errors */
+		}
+		cz_update_uvd_dpm(adev, gate);
+		if (pi->caps_uvd_pg)
+			/* power off the UVD block */
+			cz_send_msg_to_smc(adev, PPSMC_MSG_UVDPowerOFF);
+	} else {
+		if (pi->caps_uvd_pg) {
+			/* power on the UVD block */
+			if (pi->uvd_dynamic_pg)
+				cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 1);
+			else
+				cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 0);
+			/* re-init the UVD block */
+			ret = amdgpu_set_powergating_state(adev, AMDGPU_IP_BLOCK_TYPE_UVD,
+							    AMDGPU_PG_STATE_UNGATE);
+			/* enable clockgating. hw will dynamically gate/ungate clocks on the fly */
+			ret = amdgpu_set_clockgating_state(adev, AMDGPU_IP_BLOCK_TYPE_UVD,
+							    AMDGPU_CG_STATE_GATE);
+			/* XXX: check for errors */
+		}
+		cz_update_uvd_dpm(adev, gate);
+	}
+}
+
 const struct amdgpu_ip_funcs cz_dpm_ip_funcs = {
 	.early_init = cz_dpm_early_init,
-	.late_init = NULL,
+	.late_init = cz_dpm_late_init,
 	.sw_init = cz_dpm_sw_init,
 	.sw_fini = cz_dpm_sw_fini,
 	.hw_init = cz_dpm_hw_init,
@@ -1707,7 +1793,7 @@ static const struct amdgpu_dpm_funcs cz_dpm_funcs = {
 				cz_dpm_debugfs_print_current_performance_level,
 	.force_performance_level = cz_dpm_force_dpm_level,
 	.vblank_too_short = NULL,
-	.powergate_uvd = NULL,
+	.powergate_uvd = cz_dpm_powergate_uvd,
 };
 
 static void cz_dpm_set_funcs(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.h b/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
index ed6449d..782a741 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
@@ -221,6 +221,8 @@ struct cz_power_info {
 	bool uvd_power_down;
 	bool vce_power_down;
 	bool acp_power_down;
+
+	bool uvd_dynamic_pg;
 };
 
 /* cz_smc.c */
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index 20a1598..59a073a 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -1266,7 +1266,7 @@ static int vi_common_early_init(struct amdgpu_device *adev)
 	case CHIP_CARRIZO:
 		adev->has_uvd = true;
 		adev->cg_flags = 0;
-		adev->pg_flags = 0;
+		adev->pg_flags = AMDGPU_PG_SUPPORT_UVD;
 		adev->external_rev_id = adev->rev_id + 0x1;
 		if (amdgpu_smc_load_fw && smc_enabled)
 			adev->firmware.smu_load = true;
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-05-27  3:21 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27  3:19 [PATCH 00/88] amdgpu driver updates Alex Deucher
2015-05-27  3:19 ` [PATCH 29/88] drm/amdgpu: add amdgpu uapi header (v4) Alex Deucher
2015-06-05 18:57   ` Jerome Glisse
2015-06-09  2:51     ` Alex Deucher
2015-06-09  9:13       ` Marek Olšák
2015-05-27  3:19 ` [PATCH 30/88] drm/amdgpu: add atombios headers Alex Deucher
2015-05-27  3:19 ` [PATCH 31/88] drm/amdgpu: add clearstate_defs.h Alex Deucher
2015-05-27  3:19 ` [PATCH 32/88] drm/amdgpu: add ppsmc.h Alex Deucher
2015-05-27  3:19 ` [PATCH 33/88] drm/amdgpu: add amdgpu_family.h Alex Deucher
2015-05-27  3:19 ` [PATCH 34/88] drm/amdgpu: add amdgpu.h (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 36/88] drm/amdgpu: fix const warnings in amdgpu_connectors.c Alex Deucher
2015-05-27  3:19 ` [PATCH 37/88] drm/amdgpu: Do not directly dereference pointers to BIOS area Alex Deucher
2015-05-27  3:19 ` [PATCH 40/88] drm/amdgpu: add CIK pci ids Alex Deucher
2015-05-27  3:19 ` [PATCH 41/88] drm/amdgpu: add VI " Alex Deucher
2015-05-27  3:19 ` [PATCH 42/88] drm/amdgpu: drop ttm two ended allocation Alex Deucher
2015-05-27  3:19 ` [PATCH 43/88] drm/amdgpu: fix error check issue in amdgpu_mn_invalidate_range_start Alex Deucher
2015-05-27  3:19 ` [PATCH 44/88] drm/amdgpu: fix bug occurs when bo_list is NULL Alex Deucher
2015-05-27  3:19 ` [PATCH 45/88] drm/amdgpu: let bo_list handler start from 1 Alex Deucher
2015-05-27  3:19 ` [PATCH 46/88] drm/amdgpu: fix error handling in cz_dpm_hw_fini/cz_dpm_suspend Alex Deucher
2015-05-27  3:19 ` [PATCH 47/88] drm/amdgpu: memset gds_info struct in info ioctl Alex Deucher
2015-05-27  3:19 ` [PATCH 48/88] drm/amdgpu fix amdgpu.dpm=0 (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 49/88] drm/amdgpu: remove AMDGPU_GEM_CREATE_CPU_GTT_UC Alex Deucher
2015-06-06 17:08   ` Oded Gabbay
2015-06-06 19:09     ` Christian König
2015-06-06 19:32       ` Oded Gabbay
2015-06-12 15:47   ` Emil Velikov
2015-06-12 16:41     ` Bridgman, John
2015-06-12 16:57       ` Emil Velikov
2015-05-27  3:19 ` [PATCH 50/88] drm/amdgpu: fix userptr BO unpin bug (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 51/88] drm/amdgpu: fix userptr lockup Alex Deucher
2015-05-27  3:19 ` [PATCH 52/88] drm/amdgpu: remove unsafe context releasing Alex Deucher
2015-05-27  3:19 ` [PATCH 53/88] drm/amdgpu: make the CTX ioctl thread-safe Alex Deucher
2015-05-27  3:19 ` [PATCH 54/88] drm/amdgpu: allow unaligned memory access (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 55/88] drm/amdgpu: add ctx_id to the WAIT_CS IOCTL (v4) Alex Deucher
2015-05-27  3:19 ` [PATCH 56/88] drm/amdgpu: check context id for context switching (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 57/88] drm/amdgpu: add flags for amdgpu_ib structure Alex Deucher
2015-05-27  3:19 ` [PATCH 58/88] drm/amdgpu: add CE preamble flag v3 Alex Deucher
2015-05-27  3:19 ` [PATCH 59/88] drm/amdgpu: always emit GDS switch Alex Deucher
2015-05-27  3:19 ` [PATCH 60/88] drm/amdgpu: cleanup HDP flush handling Alex Deucher
2015-05-27  3:20 ` [PATCH 61/88] drm/amdgpu: fix dereference before check Alex Deucher
2015-05-27  3:20 ` [PATCH 62/88] drm/amdgpu: fix context switch Alex Deucher
2015-05-27  3:20 ` [PATCH 63/88] drm/amdgpu: expose the max virtual address Alex Deucher
2015-05-27  3:20 ` [PATCH 64/88] drm/amdgpu: do necessary NULL check Alex Deucher
2015-05-27  3:20 ` [PATCH 65/88] drm/amdgpu: switch to amdgpu folder for firmware files v2 Alex Deucher
2015-05-27  3:20 ` [PATCH 66/88] drm/amdgpu: rewording some left radeons Alex Deucher
2015-05-27  3:20 ` [PATCH 67/88] drm/amdgpu: add new bonaire pci id Alex Deucher
2015-05-27  3:20 ` [PATCH 68/88] drm/amdgpu: add some new tonga pci ids Alex Deucher
2015-05-27  3:20 ` [PATCH 69/88] drm/amdgpu: add and implement the GPU reset status query Alex Deucher
2015-05-27  3:20 ` [PATCH 70/88] drm/amdgpu: take the mode_config mutex when handling hpds Alex Deucher
2015-05-27  3:20 ` [PATCH 71/88] drm/amdgpu: make some DP parameters const Alex Deucher
2015-05-27  3:20 ` [PATCH 72/88] drm/amdgpu: simplify DPCD debug output Alex Deucher
2015-05-27  3:20 ` [PATCH 73/88] drm/amdgpu: retry dcpd fetch Alex Deucher
2015-05-27  3:20 ` [PATCH 74/88] drm/amdgpu: fix VM_CONTEXT*_PAGE_TABLE_END_ADDR handling Alex Deucher
2015-05-27  3:20 ` [PATCH 75/88] drm/amdgpu: enforce AMDGPU_GEM_CREATE_NO_CPU_ACCESS Alex Deucher
2015-05-27  3:20 ` [PATCH 76/88] drm/amdgpu: validate amdgpu_vm_bo_map parameters Alex Deucher
2015-05-27  3:20 ` [PATCH 77/88] drm/amdgpu: actually use the VM map parameters Alex Deucher
2015-05-27  3:20 ` [PATCH 78/88] drm/amdgpu: don't set unused tiling flags Alex Deucher
2015-05-27  3:20 ` [PATCH 79/88] drm/amdgpu: rework " Alex Deucher
2015-05-27  3:20 ` [PATCH 80/88] drm/amdgpu: remove unused TRACE_SYSTEM_STRING define Alex Deucher
2015-05-27  3:20 ` [PATCH 81/88] drm/amdgpu: recalculate VCE firmware BO size Alex Deucher
2015-05-27  3:20 ` [PATCH 82/88] drm/amdgpu: implement VCE two instances support Alex Deucher
2015-05-27  3:20 ` Alex Deucher [this message]
2015-05-27  3:20 ` [PATCH 84/88] drm/amdgpu: port fault_reserve_notify changes from radeon Alex Deucher
2015-05-27  3:20 ` [PATCH 85/88] drm/amdgpu: drop AMDGPU_FENCE_SIGNALED_SEQ Alex Deucher
2015-05-27  3:20 ` [PATCH 86/88] drm/amdgpu: drop allocation flag masks Alex Deucher
2015-05-27  3:20 ` [PATCH 87/88] drm/amdgpu: rename amdgpu_ip_funcs to amd_ip_funcs (v2) Alex Deucher
2015-05-27  3:20 ` [PATCH 88/88] drm/amdgpu: implement the allocation range (v2) Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432696827-3752-53-git-send-email-alexander.deucher@amd.com \
    --to=alexdeucher@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sonny.jiang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).