AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 3/3] drm/amd/display: Implement pp_smu_funcs_rv
Date: Fri, 22 Jun 2018 18:42:13 +0800	[thread overview]
Message-ID: <1529664133-5282-3-git-send-email-Rex.Zhu@amd.com> (raw)
In-Reply-To: <1529664133-5282-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>

Implement pp_smu_funcs_rv in display.
so display can call powerplay run-time service.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_services.c | 115 ++++++++++++++++++++-
 1 file changed, 114 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
index 62cf895..96744bd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
@@ -34,6 +34,8 @@
 #include "amdgpu_dm.h"
 #include "amdgpu_dm_irq.h"
 #include "amdgpu_pm.h"
+#include "core_types.h"
+#include "dm_pp_smu.h"
 
 unsigned long long dm_get_timestamp(struct dc_context *ctx)
 {
@@ -468,9 +470,120 @@ bool dm_pp_get_static_clocks(
 	return false;
 }
 
+static void pp_rv_set_display_requirement(struct pp_smu *pp,
+				struct pp_smu_display_requirement_rv *req)
+{
+	struct dc_context *ctx = pp->ctx;
+	struct amdgpu_device *adev = ctx->driver_context;
+	void *pp_handle = adev->powerplay.pp_handle;
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	struct pp_display_clock_request request;
+
+	if (!pp_funcs || !pp_funcs->display_clock_voltage_request)
+		return;
+
+	request.clock_type = dc_to_pp_clock_type(DM_PP_CLOCK_TYPE_DCFCLK);
+	request.clock_freq_in_khz = req->hard_min_dcefclk_khz;
+	pp_funcs->display_clock_voltage_request(pp_handle, &request);
+
+	request.clock_type = dc_to_pp_clock_type(DM_PP_CLOCK_TYPE_FCLK);
+	request.clock_freq_in_khz = req->hard_min_fclk_khz;
+	pp_funcs->display_clock_voltage_request(pp_handle, &request);
+}
+
+static void pp_rv_set_wm_ranges(struct pp_smu *pp,
+				struct pp_smu_wm_range_sets *range)
+{
+	struct dc_context *ctx = pp->ctx;
+	struct amdgpu_device *adev = ctx->driver_context;
+	void *pp_handle = adev->powerplay.pp_handle;
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	struct dm_pp_wm_sets_with_clock_ranges_soc15 wm_with_clock_ranges;
+	struct dm_pp_clock_range_for_dmif_wm_set_soc15 *wm_dce_clocks = wm_with_clock_ranges.wm_dmif_clocks_ranges;
+	struct dm_pp_clock_range_for_mcif_wm_set_soc15 *wm_soc_clocks = wm_with_clock_ranges.wm_mcif_clocks_ranges;
+	int32_t i;
+
+	if (!pp_funcs || !pp_funcs->set_watermarks_for_clocks_ranges || !range)
+		return;
+
+	wm_with_clock_ranges.num_wm_dmif_sets = range->num_reader_wm_sets;
+	wm_with_clock_ranges.num_wm_mcif_sets = range->num_writer_wm_sets;
+
+	if (wm_with_clock_ranges.num_wm_dmif_sets > 4 || wm_with_clock_ranges.num_wm_mcif_sets > 4)
+		return;
+
+	for (i = 0; i < wm_with_clock_ranges.num_wm_dmif_sets; i++) {
+		switch (range->reader_wm_sets[i].wm_inst) {
+		case WM_A:
+			wm_dce_clocks[i].wm_set_id = 0;
+			break;
+		case WM_B:
+			wm_dce_clocks[i].wm_set_id = 1;
+			break;
+		case WM_C:
+			wm_dce_clocks[i].wm_set_id = 2;
+			break;
+		case WM_D:
+			wm_dce_clocks[i].wm_set_id = 3;
+			break;
+		default:
+			wm_dce_clocks[i].wm_set_id = 0;
+			break;
+		}
+		wm_dce_clocks[i].wm_min_dcfclk_clk_in_khz = range->reader_wm_sets[i].min_drain_clk_khz / 10;
+		wm_dce_clocks[i].wm_max_dcfclk_clk_in_khz = range->reader_wm_sets[i].max_drain_clk_khz / 10;
+		wm_dce_clocks[i].wm_min_mem_clk_in_khz = range->reader_wm_sets[i].min_fill_clk_khz / 10;
+		wm_dce_clocks[i].wm_max_mem_clk_in_khz = range->reader_wm_sets[i].max_fill_clk_khz / 10;
+	}
+
+	for (i = 0; i < wm_with_clock_ranges.num_wm_mcif_sets; i++) {
+		switch (range->writer_wm_sets[i].wm_inst) {
+		case WM_A:
+			wm_soc_clocks[i].wm_set_id = 0;
+			break;
+		case WM_B:
+			wm_soc_clocks[i].wm_set_id = 1;
+			break;
+		case WM_C:
+			wm_soc_clocks[i].wm_set_id = 2;
+			break;
+		case WM_D:
+			wm_soc_clocks[i].wm_set_id = 3;
+			break;
+		default:
+			wm_soc_clocks[i].wm_set_id = 0;
+			break;
+		}
+		wm_soc_clocks[i].wm_min_socclk_clk_in_khz = range->writer_wm_sets[i].min_fill_clk_khz / 10;
+		wm_soc_clocks[i].wm_max_socclk_clk_in_khz = range->writer_wm_sets[i].max_fill_clk_khz / 10;
+		wm_soc_clocks[i].wm_min_mem_clk_in_khz = range->writer_wm_sets[i].min_drain_clk_khz / 10;
+		wm_soc_clocks[i].wm_max_mem_clk_in_khz = range->writer_wm_sets[i].max_drain_clk_khz / 10;
+	}
+
+	pp_funcs->set_watermarks_for_clocks_ranges(pp_handle, &wm_with_clock_ranges);
+}
+
+static void pp_rv_set_pme_wa_enable(struct pp_smu *pp)
+{
+	struct dc_context *ctx = pp->ctx;
+	struct amdgpu_device *adev = ctx->driver_context;
+	void *pp_handle = adev->powerplay.pp_handle;
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	if (!pp_funcs || !pp_funcs->notify_smu_enable_pwe)
+		return;
+
+	pp_funcs->notify_smu_enable_pwe(pp_handle);
+}
+
 void dm_pp_get_funcs_rv(
 		struct dc_context *ctx,
 		struct pp_smu_funcs_rv *funcs)
-{}
+{
+	funcs->pp_smu.ctx = ctx;
+	funcs->set_display_requirement = pp_rv_set_display_requirement;
+	funcs->set_wm_ranges = pp_rv_set_wm_ranges;
+	funcs->set_pme_wa_enable = pp_rv_set_pme_wa_enable;
+}
 
 /**** end of power component interfaces ****/
-- 
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-06-22 10:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 10:42 [PATCH 1/3] drm/amd/display: More clock types transfer between dc and pp Rex Zhu
     [not found] ` <1529664133-5282-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2018-06-22 10:42   ` [PATCH 2/3] drm/amd/pp: Export notify_smu_enable_pwe to display Rex Zhu
2018-06-22 10:42   ` Rex Zhu [this message]
     [not found]     ` <1529664133-5282-3-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2018-06-22 14:48       ` [PATCH 3/3] drm/amd/display: Implement pp_smu_funcs_rv 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=1529664133-5282-3-git-send-email-Rex.Zhu@amd.com \
    --to=rex.zhu-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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