Commit 7966f319 authored by Qingqing Zhuo's avatar Qingqing Zhuo Committed by Alex Deucher
Browse files

drm/amd/display: Introduce DML2



DC is transitioning from DML to DML2, and this commit introduces all the
required changes for some of the already available ASICs and adds the
required code infra to support new ASICs under DML2. DML2 is also a
generated code that provides better mode verification and programming
models for software/hardware, and it enables a better way to create
validation tools. This version is more like a middle step to the
complete transition to the DML2 version.

Changes since V1:
- Alex: Fix typos

Changes since V2:
- Update DC includes

Changes since V3:
- Fix 32 bit compilation issues on x86

Changes since V4:
- Avoid compilation of DML2 on some not supported 32-bit architecture
- Update commit message

Co-developed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Co-developed-by: default avatarRoman Li <roman.li@amd.com>
Signed-off-by: default avatarRoman Li <roman.li@amd.com>
Signed-off-by: default avatarQingqing Zhuo <Qingqing.Zhuo@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6e2c4941
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ ifdef CONFIG_DRM_AMD_DC_FP

KCOV_INSTRUMENT := n

DC_LIBS += dcn20
DC_LIBS += dcn10
DC_LIBS += dcn20
DC_LIBS += dcn21
DC_LIBS += dcn201
DC_LIBS += dcn30
@@ -44,6 +44,7 @@ DC_LIBS += dcn32
DC_LIBS += dcn321
DC_LIBS += dcn35
DC_LIBS += dml
DC_LIBS += dml2
endif

DC_LIBS += dce120
+39 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@

#include "hw_sequencer_private.h"

#include "dml2/dml2_internal_types.h"

#include "dce/dmub_outbox.h"

#define CTX \
@@ -2176,6 +2178,11 @@ struct dc_state *dc_create_state(struct dc *dc)

	init_state(dc, context);

#ifdef CONFIG_DRM_AMD_DC_FP
	if (dc->debug.using_dml2) {
		dml2_create(dc, &dc->dml2_options, &context->bw_ctx.dml2);
	}
#endif
	kref_init(&context->refcount);

	return context;
@@ -2185,11 +2192,25 @@ struct dc_state *dc_copy_state(struct dc_state *src_ctx)
{
	int i, j;
	struct dc_state *new_ctx = kvmalloc(sizeof(struct dc_state), GFP_KERNEL);
#ifdef CONFIG_DRM_AMD_DC_FP
	struct dml2_context *dml2 =  NULL;
#endif

	if (!new_ctx)
		return NULL;
	memcpy(new_ctx, src_ctx, sizeof(struct dc_state));

#ifdef CONFIG_DRM_AMD_DC_FP
	if (new_ctx->bw_ctx.dml2) {
		dml2 = kzalloc(sizeof(struct dml2_context), GFP_KERNEL);
		if (!dml2)
			return NULL;

		memcpy(dml2, src_ctx->bw_ctx.dml2, sizeof(struct dml2_context));
		new_ctx->bw_ctx.dml2 = dml2;
	}
#endif

	for (i = 0; i < MAX_PIPES; i++) {
			struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i];

@@ -2228,6 +2249,12 @@ static void dc_state_free(struct kref *kref)
{
	struct dc_state *context = container_of(kref, struct dc_state, refcount);
	dc_resource_state_destruct(context);

#ifdef CONFIG_DRM_AMD_DC_FP
	dml2_destroy(context->bw_ctx.dml2);
	context->bw_ctx.dml2 = 0;
#endif

	kvfree(context);
}

@@ -4679,6 +4706,9 @@ bool dc_set_power_state(
{
	struct kref refcount;
	struct display_mode_lib *dml;
#ifdef CONFIG_DRM_AMD_DC_FP
	struct dml2_context *dml2 = NULL;
#endif

	if (!dc->current_state)
		return true;
@@ -4698,6 +4728,10 @@ bool dc_set_power_state(

		break;
	default:
#ifdef CONFIG_DRM_AMD_DC_FP
		if (dc->debug.using_dml2)
			dml2 = dc->current_state->bw_ctx.dml2;
#endif
		ASSERT(dc->current_state->stream_count == 0);
		/* Zero out the current context so that on resume we start with
		 * clean state, and dc hw programming optimizations will not
@@ -4724,6 +4758,11 @@ bool dc_set_power_state(

		kfree(dml);

#ifdef CONFIG_DRM_AMD_DC_FP
		if (dc->debug.using_dml2)
			dc->current_state->bw_ctx.dml2 = dml2;
#endif

		break;
	}

+20 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "dpcd_defs.h"
#include "link_enc_cfg.h"
#include "link.h"
#include "clk_mgr.h"
#include "virtual/virtual_link_hwss.h"
#include "link/hwss/link_hwss_dio.h"
#include "link/hwss/link_hwss_dpia.h"
@@ -86,6 +87,8 @@
	dc->ctx->logger
#define DC_LOGGER_INIT(logger)

#include "dml2/dml2_wrapper.h"

#define UNABLE_TO_SPLIT -1

enum dce_version resource_parse_asic_id(struct hw_asic_id asic_id)
@@ -318,6 +321,10 @@ struct resource_pool *dc_create_resource_pool(struct dc *dc,
				res_pool->ref_clocks.xtalin_clock_inKhz;
			res_pool->ref_clocks.dchub_ref_clock_inKhz =
				res_pool->ref_clocks.xtalin_clock_inKhz;
			if ((res_pool->hubbub->funcs->get_dchub_ref_freq))
				res_pool->hubbub->funcs->get_dchub_ref_freq(res_pool->hubbub,
					res_pool->ref_clocks.dccg_ref_clock_inKhz,
					&res_pool->ref_clocks.dchub_ref_clock_inKhz);
		} else
			ASSERT_CRITICAL(false);
	}
@@ -4358,9 +4365,22 @@ void dc_resource_state_copy_construct(
{
	int i, j;
	struct kref refcount = dst_ctx->refcount;
#ifdef CONFIG_DRM_AMD_DC_FP
	struct dml2_context *dml2 = NULL;

	// Need to preserve allocated dml2 context
	if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
		dml2 = dst_ctx->bw_ctx.dml2;
#endif

	*dst_ctx = *src_ctx;

#ifdef CONFIG_DRM_AMD_DC_FP
	// Preserve allocated dml2 context
	if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
		dst_ctx->bw_ctx.dml2 = dml2;
#endif

	for (i = 0; i < MAX_PIPES; i++) {
		struct pipe_ctx *cur_pipe = &dst_ctx->res_ctx.pipe_ctx[i];

+5 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@
#include "inc/hw/dmcu.h"
#include "dml/display_mode_lib.h"

#include "dml2/dml2_wrapper.h"

struct abm_save_restore;

/* forward declaration */
@@ -942,6 +944,7 @@ struct dc_debug_options {
	bool dml_disallow_alternate_prefetch_modes;
	bool use_legacy_soc_bb_mechanism;
	bool exit_idle_opt_for_cursor_updates;
	bool using_dml2;
	bool enable_single_display_2to1_odm_policy;
	bool enable_double_buffered_dsc_pg_support;
	bool enable_dp_dig_pixel_rate_div_policy;
@@ -1049,6 +1052,8 @@ struct dc {
			struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
		} update_bw_bounding_box;
	} scratch;

	struct dml2_configuration_options dml2_options;
};

enum frame_buffer_mode {
+58 −3
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@
#include "dcn20/dcn20_vmid.h"
#include "dml/dcn32/dcn32_fpu.h"

#include "dml2/dml2_wrapper.h"

#define DC_LOGGER_INIT(logger)

enum dcn32_clk_src_array_id {
@@ -714,6 +716,7 @@ static const struct dc_debug_options debug_defaults_drv = {
	.use_max_lb = true,
	.force_disable_subvp = false,
	.exit_idle_opt_for_cursor_updates = true,
	.using_dml2 = false,
	.enable_single_display_2to1_odm_policy = true,

	/* Must match enable_single_display_2to1_odm_policy to support dynamic ODM transitions*/
@@ -1805,9 +1808,7 @@ void dcn32_add_phantom_pipes(struct dc *dc, struct dc_state *context,
	}
}

bool dcn32_validate_bandwidth(struct dc *dc,
		struct dc_state *context,
		bool fast_validate)
static bool dml1_validate(struct dc *dc, struct dc_state *context, bool fast_validate)
{
	bool out = false;

@@ -1885,6 +1886,19 @@ bool dcn32_validate_bandwidth(struct dc *dc,
	return out;
}

bool dcn32_validate_bandwidth(struct dc *dc,
		struct dc_state *context,
		bool fast_validate)
{
	bool out = false;

	if (dc->debug.using_dml2)
		out = dml2_validate(dc, context, fast_validate);
	else
		out = dml1_validate(dc, context, fast_validate);
	return out;
}

int dcn32_populate_dml_pipes_from_context(
	struct dc *dc, struct dc_state *context,
	display_e2e_pipe_params_st *pipes,
@@ -2422,6 +2436,47 @@ static bool dcn32_resource_construct(
		pool->base.oem_device = NULL;
	}

	dc->dml2_options.dcn_pipe_count = pool->base.pipe_count;
	dc->dml2_options.use_native_pstate_optimization = false;
	dc->dml2_options.use_native_soc_bb_construction = true;
	dc->dml2_options.minimize_dispclk_using_odm = true;

	dc->dml2_options.callbacks.dc = dc;
	dc->dml2_options.callbacks.build_scaling_params = &resource_build_scaling_params;
	dc->dml2_options.callbacks.can_support_mclk_switch_using_fw_based_vblank_stretch = &dcn30_can_support_mclk_switch_using_fw_based_vblank_stretch;
	dc->dml2_options.callbacks.acquire_secondary_pipe_for_mpc_odm = &dc_resource_acquire_secondary_pipe_for_mpc_odm_legacy;

	dc->dml2_options.svp_pstate.callbacks.dc = dc;
	dc->dml2_options.svp_pstate.callbacks.add_plane_to_context = &dc_add_plane_to_context;
	dc->dml2_options.svp_pstate.callbacks.add_stream_to_ctx = &dc_add_stream_to_ctx;
	dc->dml2_options.svp_pstate.callbacks.build_scaling_params = &resource_build_scaling_params;
	dc->dml2_options.svp_pstate.callbacks.create_plane = &dc_create_plane_state;
	dc->dml2_options.svp_pstate.callbacks.remove_plane_from_context = &dc_remove_plane_from_context;
	dc->dml2_options.svp_pstate.callbacks.remove_stream_from_ctx = &dc_remove_stream_from_ctx;
	dc->dml2_options.svp_pstate.callbacks.create_stream_for_sink = &dc_create_stream_for_sink;
	dc->dml2_options.svp_pstate.callbacks.plane_state_release = &dc_plane_state_release;
	dc->dml2_options.svp_pstate.callbacks.stream_release = &dc_stream_release;
	dc->dml2_options.svp_pstate.callbacks.release_dsc = &dcn20_release_dsc;

	dc->dml2_options.svp_pstate.subvp_fw_processing_delay_us = dc->caps.subvp_fw_processing_delay_us;
	dc->dml2_options.svp_pstate.subvp_prefetch_end_to_mall_start_us = dc->caps.subvp_prefetch_end_to_mall_start_us;
	dc->dml2_options.svp_pstate.subvp_pstate_allow_width_us = dc->caps.subvp_pstate_allow_width_us;
	dc->dml2_options.svp_pstate.subvp_swath_height_margin_lines = dc->caps.subvp_swath_height_margin_lines;

	dc->dml2_options.svp_pstate.force_disable_subvp = dc->debug.force_disable_subvp;
	dc->dml2_options.svp_pstate.force_enable_subvp = dc->debug.force_subvp_mclk_switch;

	dc->dml2_options.mall_cfg.cache_line_size_bytes = dc->caps.cache_line_size;
	dc->dml2_options.mall_cfg.cache_num_ways = dc->caps.cache_num_ways;
	dc->dml2_options.mall_cfg.max_cab_allocation_bytes = dc->caps.max_cab_allocation_bytes;
	dc->dml2_options.mall_cfg.mblk_height_4bpe_pixels = DCN3_2_MBLK_HEIGHT_4BPE;
	dc->dml2_options.mall_cfg.mblk_height_8bpe_pixels = DCN3_2_MBLK_HEIGHT_8BPE;
	dc->dml2_options.mall_cfg.mblk_size_bytes = DCN3_2_MALL_MBLK_SIZE_BYTES;
	dc->dml2_options.mall_cfg.mblk_width_pixels = DCN3_2_MBLK_WIDTH;

	dc->dml2_options.max_segments_per_hubp = 18;
	dc->dml2_options.det_segment_size = DCN3_2_DET_SEG_SIZE;

	if (ASICREV_IS_GC_11_0_3(dc->ctx->asic_id.hw_internal_rev) && (dc->config.sdpif_request_limit_words_per_umc == 0))
		dc->config.sdpif_request_limit_words_per_umc = 16;

Loading