Skip to contentSkip to conversation

DC Linux Patches Oct 19, 2017

PATCH In review Harry Wentland 3 participants 33 messages Oct 19, 2017 – Oct 20, 2017 4 messages not in the archive

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

cover DC Linux Patches Oct 19, 2017

* Fixed hotplug issue (mainly on HDMI, but affected DP as well)
* Use new DRM state iterators
* Couple of Dave's cleanups rerolled on new DML
* Bunch of Raven work

Anthony Koo (2):
drm/amd/display: Add APU cap in dc_caps
drm/amd/display: DMCU FW loading from PSP

Bhawanpreet Lakha (2):
drm/amd/display: Add null check for 24BPP (xfm and dpp) drm/amd/display: Atomic freesync ASSERT fix

Dave Airlie (3):
amdgpu/dc: drop dml_util_is_420
amdgpu/dc: inline dml_round_to_multiple drm/amd/display: Use DRM new-style object iterators.

Harry Wentland (6):
drm/amd/display: Small comment on dc_commit_planes_to_stream amdgpu/dc: inline a bunch of the dml wrappers. drm/amd/display: Add bunch of missing license headers in DML drm/amd/display: Cleanup some fail labels in dcn10_resource drm/amd/display: Clean some unneeded defines from ddc_service_types.h drm/amd/display: Explicit casting for grph object ids

Jerry Zuo (1):
drm/amd/display: Fix no display on Fiji

Leo (Sunpeng) Li (9):
drm/amd/display: Use new DRM API where possible drm/amd/display: Unify DRM state variable namings. drm/amd/display: Unify amdgpu_dm state variable namings. drm/amd/display: Fix typo
drm/amd/display: Remove useless pcrtc pointer drm/amd/display: Do not release DC state on S3 resume drm/amd/display: Cleanup code that enables freesync drm/amd/display: Should disable when new stream is null drm/amd/display: Only add stream to freesync when modeset required

Mikita Lipski (1):
drm/amd/display: Adding DCN1 registers

Yongqiang Sun (3):
drm/amd/display: Move lock to front end program. drm/amd/display: Check cursor address before program. drm/amd/display: Set cursor position as per address.

Yue Hin Lau (1):
drm/amd/display: cleaning up hubp for dcn

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 441 ++++++++++-----------
 drivers/gpu/drm/amd/display/dc/core/dc.c           |  60 +--
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c  |  18 +-
 drivers/gpu/drm/amd/display/dc/dc.h                |   1 +
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c      | 176 +++++++-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h      |  12 +-
 .../amd/display/dc/dce110/dce110_hw_sequencer.c    |  41 +-
 .../drm/amd/display/dc/dce110/dce110_resource.c    |   1 +
 .../gpu/drm/amd/display/dc/dce80/dce80_resource.c  |   2 +
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c  |  16 +-
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h  | 345 ++++++++--------
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c  |  26 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c  |  62 ++-
 .../amd/display/dc/dcn10/dcn10_timing_generator.h  |  33 +-
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.c  |  27 ++
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.h  |  24 +-
 .../drm/amd/display/dc/dml/display_rq_dlg_calc.c   |   2 +
 .../amd/display/dc/dml/dml1_display_rq_dlg_calc.c  |   2 +
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.c   | 119 +-----
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.h   |  17 -
 .../gpu/drm/amd/display/dc/dml/dml_inline_defs.h   | 121 ++++++
 .../gpu/drm/amd/display/dc/dml/soc_bounding_box.c  |   1 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h       |  16 +
 .../drm/amd/display/include/ddc_service_types.h    |  33 --
 .../gpu/drm/amd/display/include/grph_object_id.h   |  12 +-
 25 files changed, 894 insertions(+), 714 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
Signature · 6 lines
2.14.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): 20171019174647.21260-1-harry.wentland-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/28 drm/amd/display: Small comment on dc_commit_planes_to_stream

Having one struct on the stack was somewhat confusing. Also mention that the whole function should eventually go.

---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +7 -0
index 7a0593d4ca62..a71392ffc46d 100644
@@ -918,6 +918,12 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 	return true;
 }
 
+/*
+ * TODO this whole function needs to go
+ *
+ * dc_surface_update is needlessly complex. See if we can just replace this
+ * with a dc_plane_state and follow the atomic model a bit more closely here.
+ */
 bool dc_commit_planes_to_stream(
 		struct dc *dc,
 		struct dc_plane_state **plane_states,
@@ -925,6 +931,7 @@ bool dc_commit_planes_to_stream(
 		struct dc_stream_state *dc_stream,
 		struct dc_state *state)
 {
+	/* no need to dynamically allocate this. it's pretty small */
 	struct dc_surface_update updates[MAX_SURFACES];
 	struct dc_flip_addrs *flip_addr;
 	struct dc_plane_info *plane_info;
Signature · 6 lines
2.14.1

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

PATCH 2/28 amdgpu/dc: inline a bunch of the dml wrappers.

In reply to a message not in the archive

This reduces the code size.

This is basically a redo of Dave's change with the same name on top of the latest DML.

---
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.c  |   2 +
 .../drm/amd/display/dc/dml/display_rq_dlg_calc.c   |   2 +
 .../amd/display/dc/dml/dml1_display_rq_dlg_calc.c  |   2 +
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.c   |  67 +-------------
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.h   |  14 ---
 .../gpu/drm/amd/display/dc/dml/dml_inline_defs.h   | 102 +++++++++++++++++++++
 .../gpu/drm/amd/display/dc/dml/soc_bounding_box.c  |   1 +
 7 files changed, 110 insertions(+), 80 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c +2 -0
index e337c2cf2c09..f51a36449410 100644
@@ -1,6 +1,8 @@
 #include "display_mode_lib.h"
 #include "display_mode_vba.h"
 
+#include "dml_inline_defs.h"
+
 static const unsigned int NumberOfStates = DC__VOLTAGE_STATES;
 
 static void fetch_socbb_params(struct display_mode_lib *mode_lib);
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c +2 -0
index 657b7386021d..8ba962df42e6 100644
@@ -39,6 +39,8 @@ static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,
 		unsigned int cur_width,
 		enum cursor_bpp cur_bpp);
 
+#include "dml_inline_defs.h"
+
 static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma)
 {
 	unsigned int ret_val = 0;
drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c +2 -0
index 8229f782260b..1e4b1e383401 100644
@@ -26,6 +26,8 @@
 #include "dml1_display_rq_dlg_calc.h"
 #include "display_mode_lib.h"
 
+#include "dml_inline_defs.h"
+
 static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma)
 {
 	unsigned int ret_val = 0;
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c +1 -66

88 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h +0 -14
index ba01bbb007fc..a55f4d5af36c 100644
@@ -34,23 +34,9 @@
 #define dml_print(str, ...) {dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); }
 #define DTRACE(str, ...) {dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); }
 
-double dml_min(double a, double b);
-double dml_max(double a, double b);
-double dml_max3(double a, double b, double c);
-double dml_max4(double a, double b, double c, double d);
-double dml_max5(double a, double b, double c, double d, double e);
 bool dml_util_is_420(enum source_format_class sorce_format);
-double dml_ceil_ex(double x, double granularity);
-double dml_floor_ex(double x, double granularity);
-double dml_log(double x, double base);
-double dml_ceil(double a, double granularity);
-double dml_floor(double a, double granularity);
 double dml_round(double a);
-int dml_log2(double x);
-double dml_pow(double a, int exp);
 unsigned int dml_round_to_multiple(
 			unsigned int num, unsigned int multiple, bool up);
-double dml_fmod(double f, int val);
-double dml_ceil_2(double f);
 
 #endif /* __DC_COMMON_DEFS_H__ */
drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h new file +102 -0

102 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c +1 -0
index 8b8512528af5..bc7d8c707221 100644
@@ -26,6 +26,7 @@
 #include "display_mode_lib.h"
 #include "dc_features.h"
 
+#include "dml_inline_defs.h"
 void dml_socbb_set_latencies(soc_bounding_box_st *to_box, soc_bounding_box_st *from_box)
 {
 	to_box->dram_clock_change_latency_us = from_box->dram_clock_change_latency_us;
Signature · 6 lines
2.14.1

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

PATCH 3/28 drm/amd/display: Add bunch of missing license headers in DML

In reply to a message not in the archive

All files should have MIT headers.

---
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.c  | 25 ++++++++++++++++++++++
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.h  | 24 ++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c +25 -0
index f51a36449410..ea661ee44674 100644
@@ -1,3 +1,28 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
 #include "display_mode_lib.h"
 #include "display_mode_vba.h"
 
drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h +21 -3
index c8d1a0539541..4112409cd974 100644
@@ -1,8 +1,26 @@
 /*
- * display_mode_vba.h
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
  *
- *  Created on: Aug 18, 2017
- *      Author: dlaktyus
  */
 
 #ifndef __DML2_DISPLAY_MODE_VBA_H__
Signature · 6 lines
2.14.1

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

PATCH 4/28 amdgpu/dc: drop dml_util_is_420

In reply to a message not in the archive

From: Dave Airlie <[email protected]>

This is unused code.

---
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.c   | 33 ----------------------
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.h   |  1 -
 2 files changed, 34 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c +0 -33
index 101fb6f19c43..1683514ed0e3 100644
@@ -60,36 +60,3 @@ unsigned int dml_round_to_multiple(
 	else
 		return (num - remainder);
 }
-
-bool dml_util_is_420(enum source_format_class sorce_format)
-{
-	bool val = false;
-
-	switch (sorce_format) {
-	case dm_444_16:
-		val = false;
-		break;
-	case dm_444_32:
-		val = false;
-		break;
-	case dm_444_64:
-		val = false;
-		break;
-	case dm_420_8:
-		val = true;
-		break;
-	case dm_420_10:
-		val = true;
-		break;
-	case dm_422_8:
-		val = false;
-		break;
-	case dm_422_10:
-		val = false;
-		break;
-	default:
-		BREAK_TO_DEBUGGER();
-	}
-
-	return val;
-}
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h +0 -1
index a55f4d5af36c..e11d123ab8d9 100644
@@ -34,7 +34,6 @@
 #define dml_print(str, ...) {dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); }
 #define DTRACE(str, ...) {dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); }
 
-bool dml_util_is_420(enum source_format_class sorce_format);
 double dml_round(double a);
 unsigned int dml_round_to_multiple(
 			unsigned int num, unsigned int multiple, bool up);
Signature · 6 lines
2.14.1

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

PATCH 5/28 amdgpu/dc: inline dml_round_to_multiple

In reply to a message not in the archive

From: Dave Airlie <[email protected]>

turns out to be a win to inline this.

---
 drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c | 19 -------------------
 drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h |  2 --
 drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h | 19 +++++++++++++++++++
 3 files changed, 19 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c +0 -19
index 1683514ed0e3..b953b02a1512 100644
@@ -40,23 +40,4 @@ double dml_round(double a)
 		return floor;
 }
 
-unsigned int dml_round_to_multiple(
-	unsigned int num,
-	unsigned int multiple,
-	bool up)
-{
-	unsigned int remainder;
-
-	if (multiple == 0)
-		return num;
-
-	remainder = num % multiple;
 
-	if (remainder == 0)
-		return num;
-
-	if (up)
-		return (num + multiple - remainder);
-	else
-		return (num - remainder);
-}
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h +0 -2
index e11d123ab8d9..b2847bc469fe 100644
@@ -35,7 +35,5 @@
 #define DTRACE(str, ...) {dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); }
 
 double dml_round(double a);
-unsigned int dml_round_to_multiple(
-			unsigned int num, unsigned int multiple, bool up);
 
 #endif /* __DC_COMMON_DEFS_H__ */
drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h +19 -0
index 105c6721f901..e68086b8a22f 100644
@@ -99,4 +99,23 @@ static inline double dml_log(double x, double base)
 	return (double) dcn_bw_log(x, base);
 }
 
+static inline unsigned int dml_round_to_multiple(unsigned int num,
+						 unsigned int multiple,
+						 bool up)
+{
+	unsigned int remainder;
+
+	if (multiple == 0)
+		return num;
+
+	remainder = num % multiple;
+
+	if (remainder == 0)
+		return num;
+
+	if (up)
+		return (num + multiple - remainder);
+	else
+		return (num - remainder);
+}
 #endif
Signature · 6 lines
2.14.1

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

PATCH 6/28 drm/amd/display: Add null check for 24BPP (xfm and dpp)

In reply to a message not in the archive

From: Bhawanpreet Lakha <[email protected]>

Fixes Nullptr error when trying 24BPP

---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +12 -6
index d1cdf9f8853d..a2f9be3716cf 100644
@@ -856,6 +856,7 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
 	pipe_ctx->plane_res.scl_data.h_active = timing->h_addressable + timing->h_border_left + timing->h_border_right;
 	pipe_ctx->plane_res.scl_data.v_active = timing->v_addressable + timing->v_border_top + timing->v_border_bottom;
 
+
 	/* Taps calculations */
 	if (pipe_ctx->plane_res.xfm != NULL)
 		res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
@@ -864,16 +865,21 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
 	if (pipe_ctx->plane_res.dpp != NULL)
 		res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
 				pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
-
 	if (!res) {
 		/* Try 24 bpp linebuffer */
 		pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_24BPP;
 
-		res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
-			pipe_ctx->plane_res.xfm, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
-
-		res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
-			pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
+		if (pipe_ctx->plane_res.xfm != NULL)
+			res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
+					pipe_ctx->plane_res.xfm,
+					&pipe_ctx->plane_res.scl_data,
+					&plane_state->scaling_quality);
+
+		if (pipe_ctx->plane_res.dpp != NULL)
+			res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
+					pipe_ctx->plane_res.dpp,
+					&pipe_ctx->plane_res.scl_data,
+					&plane_state->scaling_quality);
 	}
 
 	if (res)
Signature · 6 lines
2.14.1

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

PATCH 7/28 drm/amd/display: Atomic freesync ASSERT fix

In reply to a message not in the archive

From: Bhawanpreet Lakha <[email protected]>

Changes to atomic set property for freesync.

Now In set property, just set the freesync variables and return 0. Based on the variables call mod_freesync_set_user_enable() inside commit_tail

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 85 +++++++++--------------
 1 file changed, 32 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +32 -53
index c0e9eea618e6..7f14079e3e69 100644
@@ -1703,6 +1703,7 @@ struct dm_connector_state {
 	uint8_t underscan_vborder;
 	uint8_t underscan_hborder;
 	bool underscan_enable;
+	struct mod_freesync_user_enable user_enable;
 };
 
 #define to_dm_connector_state(x)\
@@ -2531,55 +2532,6 @@ amdgpu_freesync_update_property_atomic(struct drm_connector *connector,
 
 }
 
-static int
-amdgpu_freesync_set_property_atomic(struct drm_connector *connector,
-				    struct drm_connector_state *connector_state,
-				    struct drm_property *property, uint64_t val)
-{
-	struct mod_freesync_user_enable user_enable;
-	struct drm_device *dev;
-	struct amdgpu_device *adev;
-	struct amdgpu_crtc *acrtc;
-	int ret;
-	uint64_t val_capable;
-	struct dm_crtc_state *acrtc_state;
-
-	dev  = connector->dev;
-	adev = dev->dev_private;
-	ret  = -EINVAL;
-
-	if (adev->dm.freesync_module && connector_state->crtc) {
-		ret = drm_object_property_get_value(
-				&connector->base,
-				adev->mode_info.freesync_capable_property,
-				&val_capable);
-		/* if user free sync val property is enable, but the capable
-		 * prop is not, then fail the call
-		 */
-		if (ret != 0 || (val_capable == 0 && val != 0)) {
-			ret  = -EINVAL;
-			goto release;
-		}
-
-		user_enable.enable_for_gaming = val ? true : false;
-		user_enable.enable_for_static = user_enable.enable_for_gaming;
-		user_enable.enable_for_video  = user_enable.enable_for_gaming;
-		ret  = -EINVAL;
-		acrtc = to_amdgpu_crtc(connector_state->crtc);
-		acrtc_state = to_dm_crtc_state(connector_state->crtc->state);
-
-
-		if (connector_state->connector == connector && acrtc_state->stream) {
-			mod_freesync_set_user_enable(adev->dm.freesync_module,
-						     &acrtc_state->stream, 1,
-						     &user_enable);
-			ret = 0;
-		}
-	}
-release:
-	return ret;
-}
-
 int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
 					    struct drm_connector_state *connector_state,
 					    struct drm_property *property,
@@ -2628,10 +2580,10 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
 		dm_new_state->underscan_enable = val;
 		ret = 0;
 	} else if (property == adev->mode_info.freesync_property) {
-		ret = amdgpu_freesync_set_property_atomic(connector,
-							  connector_state,
-							  property, val);
-		return ret;
+		dm_new_state->user_enable.enable_for_gaming = val;
+		dm_new_state->user_enable.enable_for_static = val;
+		dm_new_state->user_enable.enable_for_video = val;
+		ret = 0;
 	} else if (property == adev->mode_info.freesync_capable_property) {
 		ret = -EINVAL;
 		return ret;
@@ -4221,6 +4173,33 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			mod_freesync_add_stream(adev->dm.freesync_module,
 						new_stream, &aconnector->caps);
 		}
+
+		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+
+			struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
+			struct amdgpu_dm_connector *aconnector = NULL;
+			struct dm_connector_state *conn_state = NULL;
+			struct dm_crtc_state *acrtc_state = NULL;
+
+			acrtc_state = to_dm_crtc_state(acrtc->base.state);
+
+
+			aconnector =
+				amdgpu_dm_find_first_crtc_matching_connector(
+					state,
+					crtc,
+					false);
+			if (aconnector) {
+				conn_state = to_dm_connector_state(aconnector->base.state);
+
+				if (new_stream) {
+					mod_freesync_set_user_enable(adev->dm.freesync_module,
+								     &acrtc_state->stream,
+								     1,
+								     &conn_state->user_enable);
+				}
+			}
+		}
 	}
 
 	if (dm_state->context)
Signature · 6 lines
2.14.1

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

PATCH 8/28 drm/amd/display: Add APU cap in dc_caps

In reply to a message not in the archive

From: Anthony Koo <[email protected]>

Some features should only be enabled on APUs or should not be enabled on APUs.

---
 drivers/gpu/drm/amd/display/dc/core/dc.c                | 1 +
 drivers/gpu/drm/amd/display/dc/dc.h                     | 1 +
 drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c   | 2 ++
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c   | 1 +
 5 files changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -0
index a71392ffc46d..0e078c91a674 100644
@@ -551,6 +551,7 @@ static bool construct(struct dc *dc,
 
 	dc_version = resource_parse_asic_id(init_params->asic_id);
 	dc->ctx->dce_version = dc_version;
+
 #if defined(CONFIG_DRM_AMD_DC_FBC)
 	dc->ctx->fbc_gpu_addr = init_params->fbc_gpu_addr;
 #endif
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
index 9d8f4a55c74e..9ca838b3c4d7 100644
@@ -60,6 +60,7 @@ struct dc_caps {
 	unsigned int max_video_width;
 	bool dcc_const_color;
 	bool dynamic_audio;
+	bool is_apu;
 };
 
 struct dc_dcc_surface_param {
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +1 -0
index db96d2b47ff1..5b30e125b3f4 100644
@@ -1154,6 +1154,7 @@ static bool construct(
 	dc->caps.max_downscale_ratio = 150;
 	dc->caps.i2c_speed_in_khz = 100;
 	dc->caps.max_cursor_size = 128;
+	dc->caps.is_apu = true;
 
 	/*************************************************
 	 *  Create resources                             *
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +2 -0
index 9c18efd3446f..8f2bd56f3461 100644
@@ -957,6 +957,7 @@ static bool dce81_construct(
 	dc->caps.max_downscale_ratio = 200;
 	dc->caps.i2c_speed_in_khz = 40;
 	dc->caps.max_cursor_size = 128;
+	dc->caps.is_apu = true;
 
 	/*************************************************
 	 *  Create resources                             *
@@ -1121,6 +1122,7 @@ static bool dce83_construct(
 	dc->caps.max_downscale_ratio = 200;
 	dc->caps.i2c_speed_in_khz = 40;
 	dc->caps.max_cursor_size = 128;
+	dc->caps.is_apu = true;
 
 	/*************************************************
 	 *  Create resources                             *
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +1 -0
index d911590d08bc..776caf804b95 100644
@@ -1235,6 +1235,7 @@ static bool construct(
 	dc->caps.max_cursor_size = 256;
 
 	dc->caps.max_slave_planes = 1;
+	dc->caps.is_apu = true;
 
 	if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
 		dc->debug = debug_defaults_drv;
Signature · 6 lines
2.14.1

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

PATCH 9/28 drm/amd/display: Use DRM new-style object iterators.

In reply to a message not in the archive

From: Dave Airlie <[email protected]>

Use the correct for_each_new/old_* iterators instead of for_each_*

The following functions were considered:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
- Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
- drm_atomic_helper_duplicate_state is called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'

amdgpu_dm_commit_planes: use for_each_old
- Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
- Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
- Called after the state was swapped

dm_update_crtcs_state: use for_each_new
- Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
- Called before the state is swapped

v2: Split out typo fixes to a new patch.

v3: Say "functions considered" instead of "affected functions". The
latter implies that changes are made to each.

[airlied: squashed with my hacks]

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 42 +++++++++--------------
 1 file changed, 16 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16 -26
index 7f14079e3e69..bf232e131db1 100644
@@ -605,23 +605,15 @@ static int dm_suspend(void *handle)
 
 static struct amdgpu_dm_connector *
 amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
-					     struct drm_crtc *crtc,
-					     bool from_state_var)
+					     struct drm_crtc *crtc)
 {
 	uint32_t i;
 	struct drm_connector_state *conn_state;
 	struct drm_connector *connector;
 	struct drm_crtc *crtc_from_state;
 
-	for_each_connector_in_state(
-		state,
-		connector,
-		conn_state,
-		i) {
-		crtc_from_state =
-			from_state_var ?
-				conn_state->crtc :
-				connector->state->crtc;
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
+		crtc_from_state = conn_state->crtc;
 
 		if (crtc_from_state == crtc)
 			return to_amdgpu_dm_connector(connector);
@@ -689,7 +681,7 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	}
 
 	/* Force mode set in atomic comit */
-	for_each_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
 			crtc_state->active_changed = true;
 
 	cached_state = to_dm_atomic_state(adev->dm.cached_state);
@@ -3933,7 +3925,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 	unsigned long flags;
 
 	/* update planes when needed */
-	for_each_plane_in_state(state, plane, old_plane_state, i) {
+	for_each_old_plane_in_state(state, plane, old_plane_state, i) {
 		struct drm_plane_state *plane_state = plane->state;
 		struct drm_crtc *crtc = plane_state->crtc;
 		struct drm_framebuffer *fb = plane_state->fb;
@@ -4031,7 +4023,7 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 	 * it will update crtc->dm_crtc_state->stream pointer which is used in
 	 * the ISRs.
 	 */
-	for_each_crtc_in_state(state, crtc, new_state, i) {
+	for_each_new_crtc_in_state(state, crtc, new_state, i) {
 		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(crtc->state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
@@ -4069,7 +4061,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	dm_state = to_dm_atomic_state(state);
 
 	/* update changed items */
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
+	for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 		struct drm_crtc_state *new_state = crtc->state;
 
@@ -4161,8 +4153,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			aconnector =
 				amdgpu_dm_find_first_crtc_matching_connector(
 					state,
-					&new_crtcs[i]->base,
-					false);
+					&new_crtcs[i]->base);
 			if (!aconnector) {
 				DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d "
 					 "skipping freesync init\n",
@@ -4187,8 +4178,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			aconnector =
 				amdgpu_dm_find_first_crtc_matching_connector(
 					state,
-					crtc,
-					false);
+					crtc);
 			if (aconnector) {
 				conn_state = to_dm_connector_state(aconnector->base.state);
 
@@ -4223,7 +4213,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* Handle scaling and undersacn changes*/
-	for_each_connector_in_state(state, connector, old_conn_state, i) {
+	for_each_old_connector_in_state(state, connector, old_conn_state, i) {
 		struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
 		struct dm_connector_state *con_new_state =
 				to_dm_connector_state(aconnector->base.state);
@@ -4278,7 +4268,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* update planes when needed per crtc*/
-	for_each_crtc_in_state(state, pcrtc, old_crtc_state, j) {
+	for_each_old_crtc_in_state(state, pcrtc, old_crtc_state, j) {
 		new_acrtc_state = to_dm_crtc_state(pcrtc->state);
 
 		if (new_acrtc_state->stream)
@@ -4291,7 +4281,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	 * mark consumed event for drm_atomic_helper_commit_hw_done
 	 */
 	spin_lock_irqsave(&adev->ddev->event_lock, flags);
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
+	for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
 		if (acrtc->base.state->event)
@@ -4462,7 +4452,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 	/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
 	/* update changed items */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		struct amdgpu_crtc *acrtc = NULL;
 		struct amdgpu_dm_connector *aconnector = NULL;
 		struct drm_connector_state *conn_state = NULL;
@@ -4474,7 +4464,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 		new_acrtc_state = to_dm_crtc_state(crtc_state);
 		acrtc = to_amdgpu_crtc(crtc);
 
-		aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc, true);
+		aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
 
 		/* TODO This hack should go away */
 		if (aconnector && enable) {
@@ -4755,7 +4745,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * we should not add it to list of affected planes.
 	 */
 	if (state->legacy_cursor_update) {
-		for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 			if (crtc_state->color_mgmt_changed) {
 				ret = drm_atomic_add_affected_planes(state, crtc);
 				if (ret)
@@ -4815,7 +4805,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * new stream into context w\o causing full reset. Need to
 	 * decide how to handle.
 	 */
-	for_each_connector_in_state(state, connector, conn_state, i) {
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
 		struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
 		struct dm_connector_state *con_old_state =
 				to_dm_connector_state(aconnector->base.state);
Signature · 6 lines
2.14.1

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

PATCH 10/28 drm/amd/display: Use new DRM API where possible

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

To conform to DRM's new API, we should not be accessing a DRM object's internal state directly. Rather, the DRM for_each_old/new_* iterators, and drm_atomic_get_old/new_* interface should be used.

This is an ongoing process. For now, update the DRM-facing atomic functions, where the atomic state object is given.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 139 +++++++++++-----------
 1 file changed, 72 insertions(+), 67 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +72 -67
index bf232e131db1..924e33211f8b 100644
@@ -3915,29 +3915,32 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 {
 	uint32_t i;
 	struct drm_plane *plane;
-	struct drm_plane_state *old_plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct dc_stream_state *dc_stream_attach;
 	struct dc_plane_state *plane_states_constructed[MAX_SURFACES];
 	struct amdgpu_crtc *acrtc_attach = to_amdgpu_crtc(pcrtc);
-	struct dm_crtc_state *acrtc_state = to_dm_crtc_state(pcrtc->state);
+	struct drm_crtc_state *new_pcrtc_state =
+			drm_atomic_get_new_crtc_state(state, pcrtc);
+	struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	int planes_count = 0;
 	unsigned long flags;
 
 	/* update planes when needed */
-	for_each_old_plane_in_state(state, plane, old_plane_state, i) {
-		struct drm_plane_state *plane_state = plane->state;
-		struct drm_crtc *crtc = plane_state->crtc;
-		struct drm_framebuffer *fb = plane_state->fb;
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		struct drm_crtc *crtc = new_plane_state->crtc;
+		struct drm_crtc_state *new_crtc_state =
+				drm_atomic_get_new_crtc_state(state, crtc);
+		struct drm_framebuffer *fb = new_plane_state->fb;
 		bool pflip_needed;
-		struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state);
+		struct dm_plane_state *dm_plane_state = to_dm_plane_state(new_plane_state);
 
 		if (plane->type == DRM_PLANE_TYPE_CURSOR) {
 			handle_cursor_update(plane, old_plane_state);
 			continue;
 		}
 
-		if (!fb || !crtc || pcrtc != crtc || !crtc->state->active)
+		if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
 			continue;
 
 		pflip_needed = !state->allow_modeset;
@@ -3961,13 +3964,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			dc_stream_attach = acrtc_state->stream;
 			planes_count++;
 
-		} else if (crtc->state->planes_changed) {
+		} else if (new_crtc_state->planes_changed) {
 			/* Assume even ONE crtc with immediate flip means
 			 * entire can't wait for VBLANK
 			 * TODO Check if it's correct
 			 */
 			*wait_for_vblank =
-					pcrtc->state->pageflip_flags & DRM_MODE_PAGE_FLIP_ASYNC ?
+					new_pcrtc_state->pageflip_flags & DRM_MODE_PAGE_FLIP_ASYNC ?
 				false : true;
 
 			/* TODO: Needs rework for multiplane flip */
@@ -3986,7 +3989,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 	if (planes_count) {
 		unsigned long flags;
 
-		if (pcrtc->state->event) {
+		if (new_pcrtc_state->event) {
 
 			drm_crtc_vblank_get(pcrtc);
 
@@ -4012,7 +4015,7 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 				   bool nonblock)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *new_state;
+	struct drm_crtc_state *old_crtc_state, *new_state;
 	struct amdgpu_device *adev = dev->dev_private;
 	int i;
 
@@ -4023,8 +4026,8 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 	 * it will update crtc->dm_crtc_state->stream pointer which is used in
 	 * the ISRs.
 	 */
-	for_each_new_crtc_in_state(state, crtc, new_state, i) {
-		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(crtc->state);
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, i) {
+		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(old_crtc_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
 		if (drm_atomic_crtc_needs_modeset(new_state) && old_acrtc_state->stream)
@@ -4047,13 +4050,13 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	uint32_t i, j;
 	uint32_t new_crtcs_count = 0;
 	struct drm_crtc *crtc, *pcrtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct amdgpu_crtc *new_crtcs[MAX_STREAMS];
 	struct dc_stream_state *new_stream = NULL;
 	unsigned long flags;
 	bool wait_for_vblank = true;
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *old_conn_state, *new_con_state;
 	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 
 	drm_atomic_helper_update_legacy_modeset_state(dev, state);
@@ -4061,11 +4064,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	dm_state = to_dm_atomic_state(state);
 
 	/* update changed items */
-	for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
-		struct drm_crtc_state *new_state = crtc->state;
 
-		new_acrtc_state = to_dm_crtc_state(new_state);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
 
 		DRM_DEBUG_DRIVER(
@@ -4073,18 +4075,18 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			"planes_changed:%d, mode_changed:%d,active_changed:%d,"
 			"connectors_changed:%d\n",
 			acrtc->crtc_id,
-			new_state->enable,
-			new_state->active,
-			new_state->planes_changed,
-			new_state->mode_changed,
-			new_state->active_changed,
-			new_state->connectors_changed);
+			new_crtc_state->enable,
+			new_crtc_state->active,
+			new_crtc_state->planes_changed,
+			new_crtc_state->mode_changed,
+			new_crtc_state->active_changed,
+			new_crtc_state->connectors_changed);
 
 		/* handles headless hotplug case, updating new_state and
 		 * aconnector as needed
 		 */
 
-		if (modeset_required(new_state, new_acrtc_state->stream, old_acrtc_state->stream)) {
+		if (modeset_required(new_crtc_state, new_acrtc_state->stream, old_acrtc_state->stream)) {
 
 			DRM_DEBUG_DRIVER("Atomic commit: SET crtc id %d: [%p]\n", acrtc->crtc_id, acrtc);
 
@@ -4127,10 +4129,11 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			new_crtcs[new_crtcs_count] = acrtc;
 			new_crtcs_count++;
 
+			new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
 			acrtc->enabled = true;
-			acrtc->hw_mode = crtc->state->mode;
-			crtc->hwmode = crtc->state->mode;
-		} else if (modereset_required(new_state)) {
+			acrtc->hw_mode = new_crtc_state->mode;
+			crtc->hwmode = new_crtc_state->mode;
+		} else if (modereset_required(new_crtc_state)) {
 			DRM_DEBUG_DRIVER("Atomic commit: RESET. crtc id %d:[%p]\n", acrtc->crtc_id, acrtc);
 
 			/* i.e. reset mode */
@@ -4147,7 +4150,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		for (i = 0; i < new_crtcs_count; i++) {
 			struct amdgpu_dm_connector *aconnector = NULL;
 
-			new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);
+			new_crtc_state = drm_atomic_get_new_crtc_state(
+					state, &new_crtcs[i]->base);
+			new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 			new_stream = new_acrtc_state->stream;
 			aconnector =
@@ -4172,7 +4177,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			struct dm_connector_state *conn_state = NULL;
 			struct dm_crtc_state *acrtc_state = NULL;
 
-			acrtc_state = to_dm_crtc_state(acrtc->base.state);
+			new_crtc_state = drm_atomic_get_new_crtc_state(
+					state, &acrtc->base);
+			acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 
 			aconnector =
@@ -4180,7 +4187,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 					state,
 					crtc);
 			if (aconnector) {
-				conn_state = to_dm_connector_state(aconnector->base.state);
+				new_con_state = drm_atomic_get_new_connector_state(
+						state, &aconnector->base);
+				conn_state = to_dm_connector_state(new_con_state);
 
 				if (new_stream) {
 					mod_freesync_set_user_enable(adev->dm.freesync_module,
@@ -4195,11 +4204,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	if (dm_state->context)
 		WARN_ON(!dc_commit_state(dm->dc, dm_state->context));
 
-
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		new_acrtc_state = to_dm_crtc_state(crtc->state);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 		if (new_acrtc_state->stream != NULL) {
 			const struct dc_stream_status *status =
@@ -4213,24 +4221,24 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* Handle scaling and undersacn changes*/
-	for_each_old_connector_in_state(state, connector, old_conn_state, i) {
-		struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
-		struct dm_connector_state *con_new_state =
-				to_dm_connector_state(aconnector->base.state);
-		struct dm_connector_state *con_old_state =
-				to_dm_connector_state(old_conn_state);
+	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_con_state, i) {
+		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
+		struct dm_connector_state *con_old_state = to_dm_connector_state(old_conn_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
 		struct dc_stream_status *status = NULL;
 
+		if (acrtc)
+			new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
+
 		/* Skip any modesets/resets */
-		if (!acrtc || drm_atomic_crtc_needs_modeset(acrtc->base.state))
+		if (!acrtc || drm_atomic_crtc_needs_modeset(new_crtc_state))
 			continue;
 
 		/* Skip any thing not scale or underscan changes */
 		if (!is_scaling_state_different(con_new_state, con_old_state))
 			continue;
 
-		new_acrtc_state = to_dm_crtc_state(acrtc->base.state);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 		update_stream_scaling_settings(&con_new_state->base.crtc->mode,
 				con_new_state, (struct dc_stream_state *)new_acrtc_state->stream);
@@ -4258,7 +4266,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		 */
 		struct amdgpu_crtc *acrtc = new_crtcs[i];
 
-		new_acrtc_state = to_dm_crtc_state(acrtc->base.state);
+		new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 		if (adev->dm.freesync_module)
 			mod_freesync_notify_mode_change(
@@ -4268,8 +4277,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* update planes when needed per crtc*/
-	for_each_old_crtc_in_state(state, pcrtc, old_crtc_state, j) {
-		new_acrtc_state = to_dm_crtc_state(pcrtc->state);
+	for_each_new_crtc_in_state(state, pcrtc, new_crtc_state, j) {
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
 		if (new_acrtc_state->stream)
 			amdgpu_dm_commit_planes(state, dev, dm, pcrtc, &wait_for_vblank);
@@ -4281,13 +4290,12 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	 * mark consumed event for drm_atomic_helper_commit_hw_done
 	 */
 	spin_lock_irqsave(&adev->ddev->event_lock, flags);
-	for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 
-		if (acrtc->base.state->event)
-			drm_send_event_locked(dev, &crtc->state->event->base);
+		if (new_crtc_state->event)
+			drm_send_event_locked(dev, &new_crtc_state->event->base);
 
-		acrtc->base.state->event = NULL;
+		new_crtc_state->event = NULL;
 	}
 	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
 
@@ -4443,7 +4451,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 				 bool *lock_and_validation_needed)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *crtc_state;
 	int i;
 	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
@@ -4452,7 +4460,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 	/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
 	/* update changed items */
-	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
 		struct amdgpu_crtc *acrtc = NULL;
 		struct amdgpu_dm_connector *aconnector = NULL;
 		struct drm_connector_state *conn_state = NULL;
@@ -4460,7 +4468,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 		new_stream = NULL;
 
-		old_acrtc_state = to_dm_crtc_state(crtc->state);
+		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
 		new_acrtc_state = to_dm_crtc_state(crtc_state);
 		acrtc = to_amdgpu_crtc(crtc);
 
@@ -4600,7 +4608,7 @@ static int dm_update_planes_state(struct dc *dc,
 				  bool *lock_and_validation_needed)
 {
 	struct drm_crtc *new_plane_crtc, *old_plane_crtc;
-	struct drm_crtc_state *new_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct dm_crtc_state *new_acrtc_state, *old_acrtc_state;
@@ -4631,10 +4639,9 @@ static int dm_update_planes_state(struct dc *dc,
 			if (!old_plane_crtc)
 				continue;
 
-			old_acrtc_state = to_dm_crtc_state(
-					drm_atomic_get_old_crtc_state(
-							state,
-							old_plane_crtc));
+			old_crtc_state = drm_atomic_get_old_crtc_state(
+					state, old_plane_crtc);
+			old_acrtc_state = to_dm_crtc_state(old_crtc_state);
 
 			if (!old_acrtc_state->stream)
 				continue;
@@ -4722,7 +4729,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	struct dc *dc = adev->dm.dc;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	struct drm_connector *connector;
-	struct drm_connector_state *conn_state;
+	struct drm_connector_state *old_con_state, *conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *crtc_state;
 
@@ -4805,16 +4812,14 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * new stream into context w\o causing full reset. Need to
 	 * decide how to handle.
 	 */
-	for_each_new_connector_in_state(state, connector, conn_state, i) {
-		struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
-		struct dm_connector_state *con_old_state =
-				to_dm_connector_state(aconnector->base.state);
-		struct dm_connector_state *con_new_state =
-						to_dm_connector_state(conn_state);
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, conn_state, i) {
+		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
+		struct dm_connector_state *con_new_state = to_dm_connector_state(conn_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
 
 		/* Skip any modesets/resets */
-		if (!acrtc || drm_atomic_crtc_needs_modeset(acrtc->base.state))
+		if (!acrtc || drm_atomic_crtc_needs_modeset(
+				drm_atomic_get_new_crtc_state(state, &acrtc->base)))
 			continue;
 
 		/* Skip any thing not scale or underscan changes */
Signature · 6 lines
2.14.1

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

PATCH 11/28 drm/amd/display: Unify DRM state variable namings.

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

Use new_*_state and old_*_state for their respective new/old DRM object states.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 90 +++++++++++------------
 1 file changed, 45 insertions(+), 45 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +45 -45
index 924e33211f8b..1b11ea23f112 100644
@@ -608,12 +608,12 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
 					     struct drm_crtc *crtc)
 {
 	uint32_t i;
-	struct drm_connector_state *conn_state;
+	struct drm_connector_state *new_con_state;
 	struct drm_connector *connector;
 	struct drm_crtc *crtc_from_state;
 
-	for_each_new_connector_in_state(state, connector, conn_state, i) {
-		crtc_from_state = conn_state->crtc;
+	for_each_new_connector_in_state(state, connector, new_con_state, i) {
+		crtc_from_state = new_con_state->crtc;
 
 		if (crtc_from_state == crtc)
 			return to_amdgpu_dm_connector(connector);
@@ -640,10 +640,10 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	struct amdgpu_dm_connector *aconnector;
 	struct drm_connector *connector;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *new_crtc_state;
 	struct dm_crtc_state *dm_crtc_state;
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *new_plane_state;
 	struct dm_plane_state *dm_plane_state;
 	struct dm_atomic_state *cached_state;
 	int ret = 0;
@@ -681,8 +681,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	}
 
 	/* Force mode set in atomic comit */
-	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
-			crtc_state->active_changed = true;
+	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, new_crtc_state, i)
+		new_crtc_state->active_changed = true;
 
 	cached_state = to_dm_atomic_state(adev->dm.cached_state);
 
@@ -698,8 +698,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	ASSERT(cached_state->context);
 	dc_resource_state_copy_construct_current(adev->dm.dc, cached_state->context);
 
-	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i) {
-		dm_crtc_state = to_dm_crtc_state(crtc_state);
+	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, new_crtc_state, i) {
+		dm_crtc_state = to_dm_crtc_state(new_crtc_state);
 		if (dm_crtc_state->stream) {
 			WARN_ON(kref_read(&dm_crtc_state->stream->refcount) > 1);
 			dc_stream_release(dm_crtc_state->stream);
@@ -707,8 +707,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 		}
 	}
 
-	for_each_new_plane_in_state(adev->dm.cached_state, plane, plane_state, i) {
-		dm_plane_state = to_dm_plane_state(plane_state);
+	for_each_new_plane_in_state(adev->dm.cached_state, plane, new_plane_state, i) {
+		dm_plane_state = to_dm_plane_state(new_plane_state);
 		if (dm_plane_state->dc_state) {
 			WARN_ON(kref_read(&dm_plane_state->dc_state->refcount) > 1);
 			dc_plane_state_release(dm_plane_state->dc_state);
@@ -4015,7 +4015,7 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 				   bool nonblock)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *new_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct amdgpu_device *adev = dev->dev_private;
 	int i;
 
@@ -4026,11 +4026,11 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 	 * it will update crtc->dm_crtc_state->stream pointer which is used in
 	 * the ISRs.
 	 */
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(old_crtc_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		if (drm_atomic_crtc_needs_modeset(new_state) && old_acrtc_state->stream)
+		if (drm_atomic_crtc_needs_modeset(new_crtc_state) && old_acrtc_state->stream)
 			manage_dm_interrupts(adev, acrtc, false);
 	}
 	/* Add check here for SoC's that support hardware cursor plane, to
@@ -4056,7 +4056,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	unsigned long flags;
 	bool wait_for_vblank = true;
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state, *new_con_state;
+	struct drm_connector_state *old_con_state, *new_con_state;
 	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 
 	drm_atomic_helper_update_legacy_modeset_state(dev, state);
@@ -4221,9 +4221,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* Handle scaling and undersacn changes*/
-	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_con_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
 		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
-		struct dm_connector_state *con_old_state = to_dm_connector_state(old_conn_state);
+		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
 		struct dc_stream_status *status = NULL;
 
@@ -4451,7 +4451,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 				 bool *lock_and_validation_needed)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
@@ -4460,16 +4460,16 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 	/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
 	/* update changed items */
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = NULL;
 		struct amdgpu_dm_connector *aconnector = NULL;
-		struct drm_connector_state *conn_state = NULL;
+		struct drm_connector_state *new_con_state = NULL;
 		struct dm_connector_state *dm_conn_state = NULL;
 
 		new_stream = NULL;
 
 		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
-		new_acrtc_state = to_dm_crtc_state(crtc_state);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 		acrtc = to_amdgpu_crtc(crtc);
 
 		aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
@@ -4477,18 +4477,18 @@ static int dm_update_crtcs_state(struct dc *dc,
 		/* TODO This hack should go away */
 		if (aconnector && enable) {
 			// Make sure fake sink is created in plug-in scenario
-			conn_state = drm_atomic_get_connector_state(state,
+			new_con_state = drm_atomic_get_connector_state(state,
 								    &aconnector->base);
 
-			if (IS_ERR(conn_state)) {
-				ret = PTR_ERR_OR_ZERO(conn_state);
+			if (IS_ERR(new_con_state)) {
+				ret = PTR_ERR_OR_ZERO(new_con_state);
 				break;
 			}
 
-			dm_conn_state = to_dm_connector_state(conn_state);
+			dm_conn_state = to_dm_connector_state(new_con_state);
 
 			new_stream = create_stream_for_sink(aconnector,
-							    &crtc_state->mode,
+							    &new_crtc_state->mode,
 							    dm_conn_state);
 
 			/*
@@ -4508,14 +4508,14 @@ static int dm_update_crtcs_state(struct dc *dc,
 		if (dc_is_stream_unchanged(new_stream, old_acrtc_state->stream) &&
 				dc_is_stream_scaling_unchanged(new_stream, old_acrtc_state->stream)) {
 
-			crtc_state->mode_changed = false;
+			new_crtc_state->mode_changed = false;
 
 			DRM_DEBUG_DRIVER("Mode change not required, setting mode_changed to %d",
-				         crtc_state->mode_changed);
+					 new_crtc_state->mode_changed);
 		}
 
 
-		if (!drm_atomic_crtc_needs_modeset(crtc_state))
+		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
 			goto next_crtc;
 
 		DRM_DEBUG_DRIVER(
@@ -4523,12 +4523,12 @@ static int dm_update_crtcs_state(struct dc *dc,
 			"planes_changed:%d, mode_changed:%d,active_changed:%d,"
 			"connectors_changed:%d\n",
 			acrtc->crtc_id,
-			crtc_state->enable,
-			crtc_state->active,
-			crtc_state->planes_changed,
-			crtc_state->mode_changed,
-			crtc_state->active_changed,
-			crtc_state->connectors_changed);
+			new_crtc_state->enable,
+			new_crtc_state->active,
+			new_crtc_state->planes_changed,
+			new_crtc_state->mode_changed,
+			new_crtc_state->active_changed,
+			new_crtc_state->connectors_changed);
 
 		/* Remove stream for any changed/disabled CRTC */
 		if (!enable) {
@@ -4562,10 +4562,10 @@ static int dm_update_crtcs_state(struct dc *dc,
 			if (!aconnector || (!aconnector->dc_sink && aconnector->mst_port))
 				goto next_crtc;
 
-			if (modereset_required(crtc_state))
+			if (modereset_required(new_crtc_state))
 				goto next_crtc;
 
-			if (modeset_required(crtc_state, new_stream,
+			if (modeset_required(new_crtc_state, new_stream,
 					     old_acrtc_state->stream)) {
 
 				WARN_ON(new_acrtc_state->stream);
@@ -4729,9 +4729,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	struct dc *dc = adev->dm.dc;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	struct drm_connector *connector;
-	struct drm_connector_state *old_con_state, *conn_state;
+	struct drm_connector_state *old_con_state, *new_con_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 
 	/*
 	 * This bool will be set for true for any modeset/reset
@@ -4752,16 +4752,16 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * we should not add it to list of affected planes.
 	 */
 	if (state->legacy_cursor_update) {
-		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-			if (crtc_state->color_mgmt_changed) {
+		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+			if (new_crtc_state->color_mgmt_changed) {
 				ret = drm_atomic_add_affected_planes(state, crtc);
 				if (ret)
 					goto fail;
 			}
 		}
 	} else {
-		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
-			if (!crtc_state->enable)
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+			if (!new_crtc_state->enable)
 				continue;
 
 			ret = drm_atomic_add_affected_connectors(state, crtc);
@@ -4812,9 +4812,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * new stream into context w\o causing full reset. Need to
 	 * decide how to handle.
 	 */
-	for_each_oldnew_connector_in_state(state, connector, old_con_state, conn_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
 		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
-		struct dm_connector_state *con_new_state = to_dm_connector_state(conn_state);
+		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
 
 		/* Skip any modesets/resets */
Signature · 6 lines
2.14.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): 20171019174647.21260-12-harry.wentland-5C7GfCeVMHo@public.gmane.org

#14 lore raw

Re: [PATCH 11/28] drm/amd/display: Unify DRM state variable namings.

This fails to apply to drm-next even with 3-way merge enabled.

error: sha1 information is lacking or useless (drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c).
error: could not build fake ancestor
Patch failed at 0011 drm/amd/display: Unify DRM state variable namings.

Tom

Quoted 261 lines · Harry Wentland

From: "Leo (Sunpeng) Li" <[email protected]>

Use new_*_state and old_*_state for their respective new/old DRM object states.

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 90 +++++++++++------------
  1 file changed, 45 insertions(+), 45 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +43 -43
index 924e33211f8b..1b11ea23f112 100644
@@ -608,12 +608,12 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
  					     struct drm_crtc *crtc)
  {
  	uint32_t i;
-	struct drm_connector_state *conn_state;
+	struct drm_connector_state *new_con_state;
  	struct drm_connector *connector;
  	struct drm_crtc *crtc_from_state;
 
-	for_each_new_connector_in_state(state, connector, conn_state, i) {
-		crtc_from_state = conn_state->crtc;
+	for_each_new_connector_in_state(state, connector, new_con_state, i) {
+		crtc_from_state = new_con_state->crtc;
 
  		if (crtc_from_state == crtc)
  			return to_amdgpu_dm_connector(connector);
@@ -640,10 +640,10 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
  	struct amdgpu_dm_connector *aconnector;
  	struct drm_connector *connector;
  	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *new_crtc_state;
  	struct dm_crtc_state *dm_crtc_state;
  	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *new_plane_state;
  	struct dm_plane_state *dm_plane_state;
  	struct dm_atomic_state *cached_state;
  	int ret = 0;
@@ -681,8 +681,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
  	}
 
  	/* Force mode set in atomic comit */
-	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
-			crtc_state->active_changed = true;
+	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, new_crtc_state, i)
+		new_crtc_state->active_changed = true;
 
  	cached_state = to_dm_atomic_state(adev->dm.cached_state);
 
@@ -698,8 +698,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
  	ASSERT(cached_state->context);
  	dc_resource_state_copy_construct_current(adev->dm.dc, cached_state->context);
 
-	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i) {
-		dm_crtc_state = to_dm_crtc_state(crtc_state);
+	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, new_crtc_state, i) {
+		dm_crtc_state = to_dm_crtc_state(new_crtc_state);
  		if (dm_crtc_state->stream) {
  			WARN_ON(kref_read(&dm_crtc_state->stream->refcount) > 1);
  			dc_stream_release(dm_crtc_state->stream);
@@ -707,8 +707,8 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
  		}
  	}
 
-	for_each_new_plane_in_state(adev->dm.cached_state, plane, plane_state, i) {
-		dm_plane_state = to_dm_plane_state(plane_state);
+	for_each_new_plane_in_state(adev->dm.cached_state, plane, new_plane_state, i) {
+		dm_plane_state = to_dm_plane_state(new_plane_state);
  		if (dm_plane_state->dc_state) {
  			WARN_ON(kref_read(&dm_plane_state->dc_state->refcount) > 1);
  			dc_plane_state_release(dm_plane_state->dc_state);
@@ -4015,7 +4015,7 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
  				   bool nonblock)
  {
  	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *new_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
  	struct amdgpu_device *adev = dev->dev_private;
  	int i;
 
@@ -4026,11 +4026,11 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
  	 * it will update crtc->dm_crtc_state->stream pointer which is used in
  	 * the ISRs.
  	 */
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
  		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(old_crtc_state);
  		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		if (drm_atomic_crtc_needs_modeset(new_state) && old_acrtc_state->stream)
+		if (drm_atomic_crtc_needs_modeset(new_crtc_state) && old_acrtc_state->stream)
  			manage_dm_interrupts(adev, acrtc, false);
  	}
  	/* Add check here for SoC's that support hardware cursor plane, to
@@ -4056,7 +4056,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
  	unsigned long flags;
  	bool wait_for_vblank = true;
  	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state, *new_con_state;
+	struct drm_connector_state *old_con_state, *new_con_state;
  	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 
  	drm_atomic_helper_update_legacy_modeset_state(dev, state);
@@ -4221,9 +4221,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
  	}
 
  	/* Handle scaling and undersacn changes*/
-	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_con_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
  		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
-		struct dm_connector_state *con_old_state = to_dm_connector_state(old_conn_state);
+		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
  		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
  		struct dc_stream_status *status = NULL;
 
@@ -4451,7 +4451,7 @@ static int dm_update_crtcs_state(struct dc *dc,
  				 bool *lock_and_validation_needed)
  {
  	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
  	int i;
  	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
  	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
@@ -4460,16 +4460,16 @@ static int dm_update_crtcs_state(struct dc *dc,
 
  	/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
  	/* update changed items */
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
  		struct amdgpu_crtc *acrtc = NULL;
  		struct amdgpu_dm_connector *aconnector = NULL;
-		struct drm_connector_state *conn_state = NULL;
+		struct drm_connector_state *new_con_state = NULL;
  		struct dm_connector_state *dm_conn_state = NULL;
 
  		new_stream = NULL;
 
  		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
-		new_acrtc_state = to_dm_crtc_state(crtc_state);
+		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
  		acrtc = to_amdgpu_crtc(crtc);
 
  		aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
@@ -4477,18 +4477,18 @@ static int dm_update_crtcs_state(struct dc *dc,
  		/* TODO This hack should go away */
  		if (aconnector && enable) {
  			// Make sure fake sink is created in plug-in scenario
-			conn_state = drm_atomic_get_connector_state(state,
+			new_con_state = drm_atomic_get_connector_state(state,
  								    &aconnector->base);
 
-			if (IS_ERR(conn_state)) {
-				ret = PTR_ERR_OR_ZERO(conn_state);
+			if (IS_ERR(new_con_state)) {
+				ret = PTR_ERR_OR_ZERO(new_con_state);
  				break;
  			}
 
-			dm_conn_state = to_dm_connector_state(conn_state);
+			dm_conn_state = to_dm_connector_state(new_con_state);
 
  			new_stream = create_stream_for_sink(aconnector,
-							    &crtc_state->mode,
+							    &new_crtc_state->mode,
  							    dm_conn_state);
 
  			/*
@@ -4508,14 +4508,14 @@ static int dm_update_crtcs_state(struct dc *dc,
  		if (dc_is_stream_unchanged(new_stream, old_acrtc_state->stream) &&
  				dc_is_stream_scaling_unchanged(new_stream, old_acrtc_state->stream)) {
 
-			crtc_state->mode_changed = false;
+			new_crtc_state->mode_changed = false;
 
  			DRM_DEBUG_DRIVER("Mode change not required, setting mode_changed to %d",
-				         crtc_state->mode_changed);
+					 new_crtc_state->mode_changed);
  		}
 
 
-		if (!drm_atomic_crtc_needs_modeset(crtc_state))
+		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
  			goto next_crtc;
 
  		DRM_DEBUG_DRIVER(
@@ -4523,12 +4523,12 @@ static int dm_update_crtcs_state(struct dc *dc,
  			"planes_changed:%d, mode_changed:%d,active_changed:%d,"
  			"connectors_changed:%d\n",
  			acrtc->crtc_id,
-			crtc_state->enable,
-			crtc_state->active,
-			crtc_state->planes_changed,
-			crtc_state->mode_changed,
-			crtc_state->active_changed,
-			crtc_state->connectors_changed);
+			new_crtc_state->enable,
+			new_crtc_state->active,
+			new_crtc_state->planes_changed,
+			new_crtc_state->mode_changed,
+			new_crtc_state->active_changed,
+			new_crtc_state->connectors_changed);
 
  		/* Remove stream for any changed/disabled CRTC */
  		if (!enable) {
@@ -4562,10 +4562,10 @@ static int dm_update_crtcs_state(struct dc *dc,
  			if (!aconnector || (!aconnector->dc_sink && aconnector->mst_port))
  				goto next_crtc;
 
-			if (modereset_required(crtc_state))
+			if (modereset_required(new_crtc_state))
  				goto next_crtc;
 
-			if (modeset_required(crtc_state, new_stream,
+			if (modeset_required(new_crtc_state, new_stream,
  					     old_acrtc_state->stream)) {
 
  				WARN_ON(new_acrtc_state->stream);
@@ -4729,9 +4729,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
  	struct dc *dc = adev->dm.dc;
  	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
  	struct drm_connector *connector;
-	struct drm_connector_state *old_con_state, *conn_state;
+	struct drm_connector_state *old_con_state, *new_con_state;
  	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 
  	/*
  	 * This bool will be set for true for any modeset/reset
@@ -4752,16 +4752,16 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
  	 * we should not add it to list of affected planes.
  	 */
  	if (state->legacy_cursor_update) {
-		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-			if (crtc_state->color_mgmt_changed) {
+		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+			if (new_crtc_state->color_mgmt_changed) {
  				ret = drm_atomic_add_affected_planes(state, crtc);
  				if (ret)
  					goto fail;
  			}
  		}
  	} else {
-		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
-			if (!crtc_state->enable)
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+			if (!new_crtc_state->enable)
  				continue;
 
  			ret = drm_atomic_add_affected_connectors(state, crtc);
@@ -4812,9 +4812,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
  	 * new stream into context w\o causing full reset. Need to

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int amdgpu_dm_atomic_check(struct drm_device *dev, · line 4820

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -2
  	 * decide how to handle.
  	 */
-	for_each_oldnew_connector_in_state(state, connector, old_con_state, conn_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
  		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
-		struct dm_connector_state *con_new_state = to_dm_connector_state(conn_state);
+		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
  		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
 
  		/* Skip any modesets/resets */

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

#15 lore raw

PATCH 12/28 drm/amd/display: Unify amdgpu_dm state variable namings.

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

Use dm_new_*_state and dm_old_*_state for their respective amdgpu_dm new and old object states. Helps with readability, and enforces use of new DRM api (choose either new, or old).

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 168 +++++++++++-----------
 1 file changed, 84 insertions(+), 84 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +84 -84
index 1b11ea23f112..cc4cf3dab1ae 100644
@@ -641,10 +641,10 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	struct drm_connector *connector;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
-	struct dm_crtc_state *dm_crtc_state;
+	struct dm_crtc_state *dm_new_crtc_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *new_plane_state;
-	struct dm_plane_state *dm_plane_state;
+	struct dm_plane_state *dm_new_plane_state;
 	struct dm_atomic_state *cached_state;
 	int ret = 0;
 	int i;
@@ -699,20 +699,20 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	dc_resource_state_copy_construct_current(adev->dm.dc, cached_state->context);
 
 	for_each_new_crtc_in_state(adev->dm.cached_state, crtc, new_crtc_state, i) {
-		dm_crtc_state = to_dm_crtc_state(new_crtc_state);
-		if (dm_crtc_state->stream) {
-			WARN_ON(kref_read(&dm_crtc_state->stream->refcount) > 1);
-			dc_stream_release(dm_crtc_state->stream);
-			dm_crtc_state->stream = NULL;
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+		if (dm_new_crtc_state->stream) {
+			WARN_ON(kref_read(&dm_new_crtc_state->stream->refcount) > 1);
+			dc_stream_release(dm_new_crtc_state->stream);
+			dm_new_crtc_state->stream = NULL;
 		}
 	}
 
 	for_each_new_plane_in_state(adev->dm.cached_state, plane, new_plane_state, i) {
-		dm_plane_state = to_dm_plane_state(new_plane_state);
-		if (dm_plane_state->dc_state) {
-			WARN_ON(kref_read(&dm_plane_state->dc_state->refcount) > 1);
-			dc_plane_state_release(dm_plane_state->dc_state);
-			dm_plane_state->dc_state = NULL;
+		dm_new_plane_state = to_dm_plane_state(new_plane_state);
+		if (dm_new_plane_state->dc_state) {
+			WARN_ON(kref_read(&dm_new_plane_state->dc_state->refcount) > 1);
+			dc_plane_state_release(dm_new_plane_state->dc_state);
+			dm_new_plane_state->dc_state = NULL;
 		}
 	}
 
@@ -3933,7 +3933,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 				drm_atomic_get_new_crtc_state(state, crtc);
 		struct drm_framebuffer *fb = new_plane_state->fb;
 		bool pflip_needed;
-		struct dm_plane_state *dm_plane_state = to_dm_plane_state(new_plane_state);
+		struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state);
 
 		if (plane->type == DRM_PLANE_TYPE_CURSOR) {
 			handle_cursor_update(plane, old_plane_state);
@@ -3957,9 +3957,9 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 		spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 
 		if (!pflip_needed) {
-			WARN_ON(!dm_plane_state->dc_state);
+			WARN_ON(!dm_new_plane_state->dc_state);
 
-			plane_states_constructed[planes_count] = dm_plane_state->dc_state;
+			plane_states_constructed[planes_count] = dm_new_plane_state->dc_state;
 
 			dc_stream_attach = acrtc_state->stream;
 			planes_count++;
@@ -4027,10 +4027,10 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
 	 * the ISRs.
 	 */
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
-		struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(old_crtc_state);
+		struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		if (drm_atomic_crtc_needs_modeset(new_crtc_state) && old_acrtc_state->stream)
+		if (drm_atomic_crtc_needs_modeset(new_crtc_state) && dm_old_crtc_state->stream)
 			manage_dm_interrupts(adev, acrtc, false);
 	}
 	/* Add check here for SoC's that support hardware cursor plane, to
@@ -4057,7 +4057,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	bool wait_for_vblank = true;
 	struct drm_connector *connector;
 	struct drm_connector_state *old_con_state, *new_con_state;
-	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
+	struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
 
 	drm_atomic_helper_update_legacy_modeset_state(dev, state);
 
@@ -4067,8 +4067,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
-		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
 
 		DRM_DEBUG_DRIVER(
 			"amdgpu_crtc id:%d crtc_state_flags: enable:%d, active:%d, "
@@ -4086,11 +4086,11 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		 * aconnector as needed
 		 */
 
-		if (modeset_required(new_crtc_state, new_acrtc_state->stream, old_acrtc_state->stream)) {
+		if (modeset_required(new_crtc_state, dm_new_crtc_state->stream, dm_old_crtc_state->stream)) {
 
 			DRM_DEBUG_DRIVER("Atomic commit: SET crtc id %d: [%p]\n", acrtc->crtc_id, acrtc);
 
-			if (!new_acrtc_state->stream) {
+			if (!dm_new_crtc_state->stream) {
 				/*
 				 * this could happen because of issues with
 				 * userspace notifications delivery.
@@ -4112,8 +4112,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			}
 
 
-			if (old_acrtc_state->stream)
-				remove_stream(adev, acrtc, old_acrtc_state->stream);
+			if (dm_old_crtc_state->stream)
+				remove_stream(adev, acrtc, dm_old_crtc_state->stream);
 
 
 			/*
@@ -4137,8 +4137,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			DRM_DEBUG_DRIVER("Atomic commit: RESET. crtc id %d:[%p]\n", acrtc->crtc_id, acrtc);
 
 			/* i.e. reset mode */
-			if (old_acrtc_state->stream)
-				remove_stream(adev, acrtc, old_acrtc_state->stream);
+			if (dm_old_crtc_state->stream)
+				remove_stream(adev, acrtc, dm_old_crtc_state->stream);
 		}
 	} /* for_each_crtc_in_state() */
 
@@ -4152,9 +4152,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 
 			new_crtc_state = drm_atomic_get_new_crtc_state(
 					state, &new_crtcs[i]->base);
-			new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-			new_stream = new_acrtc_state->stream;
+			new_stream = dm_new_crtc_state->stream;
 			aconnector =
 				amdgpu_dm_find_first_crtc_matching_connector(
 					state,
@@ -4174,7 +4174,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 
 			struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 			struct amdgpu_dm_connector *aconnector = NULL;
-			struct dm_connector_state *conn_state = NULL;
+			struct dm_connector_state *dm_new_con_state = NULL;
 			struct dm_crtc_state *acrtc_state = NULL;
 
 			new_crtc_state = drm_atomic_get_new_crtc_state(
@@ -4189,13 +4189,13 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			if (aconnector) {
 				new_con_state = drm_atomic_get_new_connector_state(
 						state, &aconnector->base);
-				conn_state = to_dm_connector_state(new_con_state);
+				dm_new_con_state = to_dm_connector_state(new_con_state);
 
 				if (new_stream) {
 					mod_freesync_set_user_enable(adev->dm.freesync_module,
 								     &acrtc_state->stream,
 								     1,
-								     &conn_state->user_enable);
+								     &dm_new_con_state->user_enable);
 				}
 			}
 		}
@@ -4207,14 +4207,14 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
 
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-		if (new_acrtc_state->stream != NULL) {
+		if (dm_new_crtc_state->stream != NULL) {
 			const struct dc_stream_status *status =
-					dc_stream_get_status(new_acrtc_state->stream);
+					dc_stream_get_status(dm_new_crtc_state->stream);
 
 			if (!status)
-				DC_ERR("got no status for stream %p on acrtc%p\n", new_acrtc_state->stream, acrtc);
+				DC_ERR("got no status for stream %p on acrtc%p\n", dm_new_crtc_state->stream, acrtc);
 			else
 				acrtc->otg_inst = status->primary_otg_inst;
 		}
@@ -4222,9 +4222,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 
 	/* Handle scaling and undersacn changes*/
 	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
-		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
-		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
+		struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
+		struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state);
+		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
 		struct dc_stream_status *status = NULL;
 
 		if (acrtc)
@@ -4235,19 +4235,19 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 			continue;
 
 		/* Skip any thing not scale or underscan changes */
-		if (!is_scaling_state_different(con_new_state, con_old_state))
+		if (!is_scaling_state_different(dm_new_con_state, dm_old_con_state))
 			continue;
 
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-		update_stream_scaling_settings(&con_new_state->base.crtc->mode,
-				con_new_state, (struct dc_stream_state *)new_acrtc_state->stream);
+		update_stream_scaling_settings(&dm_new_con_state->base.crtc->mode,
+				dm_new_con_state, (struct dc_stream_state *)dm_new_crtc_state->stream);
 
-		status = dc_stream_get_status(new_acrtc_state->stream);
+		status = dc_stream_get_status(dm_new_crtc_state->stream);
 		WARN_ON(!status);
 		WARN_ON(!status->plane_count);
 
-		if (!new_acrtc_state->stream)
+		if (!dm_new_crtc_state->stream)
 			continue;
 
 		/*TODO How it works with MPO ?*/
@@ -4255,7 +4255,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 				dm->dc,
 				status->plane_states,
 				status->plane_count,
-				new_acrtc_state->stream,
+				dm_new_crtc_state->stream,
 				dm_state->context))
 			dm_error("%s: Failed to update stream scaling!\n", __func__);
 	}
@@ -4267,20 +4267,20 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		struct amdgpu_crtc *acrtc = new_crtcs[i];
 
 		new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
 		if (adev->dm.freesync_module)
 			mod_freesync_notify_mode_change(
-				adev->dm.freesync_module, &new_acrtc_state->stream, 1);
+				adev->dm.freesync_module, &dm_new_crtc_state->stream, 1);
 
 		manage_dm_interrupts(adev, acrtc, true);
 	}
 
 	/* update planes when needed per crtc*/
 	for_each_new_crtc_in_state(state, pcrtc, new_crtc_state, j) {
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-		if (new_acrtc_state->stream)
+		if (dm_new_crtc_state->stream)
 			amdgpu_dm_commit_planes(state, dev, dm, pcrtc, &wait_for_vblank);
 	}
 
@@ -4453,7 +4453,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
-	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
+	struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
 	struct dc_stream_state *new_stream;
 	int ret = 0;
@@ -4468,8 +4468,8 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 		new_stream = NULL;
 
-		old_acrtc_state = to_dm_crtc_state(old_crtc_state);
-		new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+		dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 		acrtc = to_amdgpu_crtc(crtc);
 
 		aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
@@ -4505,8 +4505,8 @@ static int dm_update_crtcs_state(struct dc *dc,
 			}
 		}
 
-		if (dc_is_stream_unchanged(new_stream, old_acrtc_state->stream) &&
-				dc_is_stream_scaling_unchanged(new_stream, old_acrtc_state->stream)) {
+		if (dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) &&
+				dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream)) {
 
 			new_crtc_state->mode_changed = false;
 
@@ -4533,7 +4533,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 		/* Remove stream for any changed/disabled CRTC */
 		if (!enable) {
 
-			if (!old_acrtc_state->stream)
+			if (!dm_old_crtc_state->stream)
 				goto next_crtc;
 
 			DRM_DEBUG_DRIVER("Disabling DRM crtc: %d\n",
@@ -4543,13 +4543,13 @@ static int dm_update_crtcs_state(struct dc *dc,
 			if (dc_remove_stream_from_ctx(
 					dc,
 					dm_state->context,
-					old_acrtc_state->stream) != DC_OK) {
+					dm_old_crtc_state->stream) != DC_OK) {
 				ret = -EINVAL;
 				goto fail;
 			}
 
-			dc_stream_release(old_acrtc_state->stream);
-			new_acrtc_state->stream = NULL;
+			dc_stream_release(dm_old_crtc_state->stream);
+			dm_new_crtc_state->stream = NULL;
 
 			*lock_and_validation_needed = true;
 
@@ -4566,11 +4566,11 @@ static int dm_update_crtcs_state(struct dc *dc,
 				goto next_crtc;
 
 			if (modeset_required(new_crtc_state, new_stream,
-					     old_acrtc_state->stream)) {
+					     dm_old_crtc_state->stream)) {
 
-				WARN_ON(new_acrtc_state->stream);
+				WARN_ON(dm_new_crtc_state->stream);
 
-				new_acrtc_state->stream = new_stream;
+				dm_new_crtc_state->stream = new_stream;
 				dc_stream_retain(new_stream);
 
 				DRM_DEBUG_DRIVER("Enabling DRM crtc: %d\n",
@@ -4579,7 +4579,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 				if (dc_add_stream_to_ctx(
 						dc,
 						dm_state->context,
-						new_acrtc_state->stream) != DC_OK) {
+						dm_new_crtc_state->stream) != DC_OK) {
 					ret = -EINVAL;
 					goto fail;
 				}
@@ -4611,9 +4611,9 @@ static int dm_update_planes_state(struct dc *dc,
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
-	struct dm_crtc_state *new_acrtc_state, *old_acrtc_state;
+	struct dm_crtc_state *dm_new_crtc_state, *dm_old_crtc_state;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
-	struct dm_plane_state *new_dm_plane_state, *old_dm_plane_state;
+	struct dm_plane_state *dm_new_plane_state, *dm_old_plane_state;
 	int i ;
 	/* TODO return page_flip_needed() function */
 	bool pflip_needed  = !state->allow_modeset;
@@ -4626,8 +4626,8 @@ static int dm_update_planes_state(struct dc *dc,
 	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		new_plane_crtc = new_plane_state->crtc;
 		old_plane_crtc = old_plane_state->crtc;
-		new_dm_plane_state = to_dm_plane_state(new_plane_state);
-		old_dm_plane_state = to_dm_plane_state(old_plane_state);
+		dm_new_plane_state = to_dm_plane_state(new_plane_state);
+		dm_old_plane_state = to_dm_plane_state(old_plane_state);
 
 		/*TODO Implement atomic check for cursor plane */
 		if (plane->type == DRM_PLANE_TYPE_CURSOR)
@@ -4641,9 +4641,9 @@ static int dm_update_planes_state(struct dc *dc,
 
 			old_crtc_state = drm_atomic_get_old_crtc_state(
 					state, old_plane_crtc);
-			old_acrtc_state = to_dm_crtc_state(old_crtc_state);
+			dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
 
-			if (!old_acrtc_state->stream)
+			if (!dm_old_crtc_state->stream)
 				continue;
 
 			DRM_DEBUG_DRIVER("Disabling DRM plane: %d on DRM crtc %d\n",
@@ -4651,8 +4651,8 @@ static int dm_update_planes_state(struct dc *dc,
 
 			if (!dc_remove_plane_from_context(
 					dc,
-					old_acrtc_state->stream,
-					old_dm_plane_state->dc_state,
+					dm_old_crtc_state->stream,
+					dm_old_plane_state->dc_state,
 					dm_state->context)) {
 
 				ret = EINVAL;
@@ -4660,8 +4660,8 @@ static int dm_update_planes_state(struct dc *dc,
 			}
 
 
-			dc_plane_state_release(old_dm_plane_state->dc_state);
-			new_dm_plane_state->dc_state = NULL;
+			dc_plane_state_release(dm_old_plane_state->dc_state);
+			dm_new_plane_state->dc_state = NULL;
 
 			*lock_and_validation_needed = true;
 
@@ -4674,27 +4674,27 @@ static int dm_update_planes_state(struct dc *dc,
 				continue;
 
 			new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_crtc);
-			new_acrtc_state = to_dm_crtc_state(new_crtc_state);
+			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-			if (!new_acrtc_state->stream)
+			if (!dm_new_crtc_state->stream)
 				continue;
 
 
-			WARN_ON(new_dm_plane_state->dc_state);
+			WARN_ON(dm_new_plane_state->dc_state);
 
-			new_dm_plane_state->dc_state = dc_create_plane_state(dc);
+			dm_new_plane_state->dc_state = dc_create_plane_state(dc);
 
 			DRM_DEBUG_DRIVER("Enabling DRM plane: %d on DRM crtc %d\n",
 					plane->base.id, new_plane_crtc->base.id);
 
-			if (!new_dm_plane_state->dc_state) {
+			if (!dm_new_plane_state->dc_state) {
 				ret = -EINVAL;
 				return ret;
 			}
 
 			ret = fill_plane_attributes(
 				new_plane_crtc->dev->dev_private,
-				new_dm_plane_state->dc_state,
+				dm_new_plane_state->dc_state,
 				new_plane_state,
 				new_crtc_state,
 				false);
@@ -4704,8 +4704,8 @@ static int dm_update_planes_state(struct dc *dc,
 
 			if (!dc_add_plane_to_context(
 					dc,
-					new_acrtc_state->stream,
-					new_dm_plane_state->dc_state,
+					dm_new_crtc_state->stream,
+					dm_new_plane_state->dc_state,
 					dm_state->context)) {
 
 				ret = -EINVAL;
@@ -4813,9 +4813,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 * decide how to handle.
 	 */
 	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
-		struct dm_connector_state *con_old_state = to_dm_connector_state(old_con_state);
-		struct dm_connector_state *con_new_state = to_dm_connector_state(new_con_state);
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
+		struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state);
+		struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
+		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
 
 		/* Skip any modesets/resets */
 		if (!acrtc || drm_atomic_crtc_needs_modeset(
@@ -4823,7 +4823,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 			continue;
 
 		/* Skip any thing not scale or underscan changes */
-		if (!is_scaling_state_different(con_new_state, con_old_state))
+		if (!is_scaling_state_different(dm_new_con_state, dm_old_con_state))
 			continue;
 
 		lock_and_validation_needed = true;
Signature · 6 lines
2.14.1

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

PATCH 13/28 drm/amd/display: Fix typo

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

undersacn -> underscan

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -2
index cc4cf3dab1ae..113b6df6ac4a 100644
@@ -4220,7 +4220,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		}
 	}
 
-	/* Handle scaling and undersacn changes*/
+	/* Handle scaling and underscan changes*/
 	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
 		struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
 		struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state);
@@ -4807,7 +4807,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	 if (ret)
 		 goto fail;
 
-	/* Check scaling and undersacn changes*/
+	/* Check scaling and underscan changes*/
 	/*TODO Removed scaling changes validation due to inability to commit
 	 * new stream into context w\o causing full reset. Need to
 	 * decide how to handle.
Signature · 6 lines
2.14.1

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

PATCH 14/28 drm/amd/display: Remove useless pcrtc pointer

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

in amdgpu_dm_atomic_commit_tail. Just use crtc instead.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -3
index 113b6df6ac4a..8910a820fbf5 100644
@@ -4049,7 +4049,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	struct dm_atomic_state *dm_state;
 	uint32_t i, j;
 	uint32_t new_crtcs_count = 0;
-	struct drm_crtc *crtc, *pcrtc;
+	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct amdgpu_crtc *new_crtcs[MAX_STREAMS];
 	struct dc_stream_state *new_stream = NULL;
@@ -4277,11 +4277,11 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* update planes when needed per crtc*/
-	for_each_new_crtc_in_state(state, pcrtc, new_crtc_state, j) {
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, j) {
 		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
 		if (dm_new_crtc_state->stream)
-			amdgpu_dm_commit_planes(state, dev, dm, pcrtc, &wait_for_vblank);
+			amdgpu_dm_commit_planes(state, dev, dm, crtc, &wait_for_vblank);
 	}
 
 
Signature · 6 lines
2.14.1

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

PATCH 15/28 drm/amd/display: Do not release DC state on S3 resume

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

Because of the following patch:

Leo (Sunpeng) Li Move copy_construct from state_alloc to atomic_check

We do not allocate the DC state within dm_atomic_state_alloc anymore.

Since this function is a part of the S3 resume code path, we should not release the state when refreshing it within amdgpu_dm_display_resume. Just create it, as it has already been freed.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
index 8910a820fbf5..a6424eb1c1a5 100644
@@ -691,8 +691,6 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
 	 * disabled. Refresh cached state to match actual current state before
 	 * restoring it.
 	 */
-	WARN_ON(kref_read(&cached_state->context->refcount) > 1);
-	dc_release_state(cached_state->context);
 
 	cached_state->context = dc_create_state();
 	ASSERT(cached_state->context);
Signature · 6 lines
2.14.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): 20171019174647.21260-16-harry.wentland-5C7GfCeVMHo@public.gmane.org

#20 lore raw

Re: [PATCH 15/28] drm/amd/display: Do not release DC state on S3 resume

Quoted 24 lines · Harry Wentland

From: "Leo (Sunpeng) Li" <[email protected]>

Because of the following patch:

Leo (Sunpeng) Li Move copy_construct from state_alloc to atomic_check

We do not allocate the DC state within dm_atomic_state_alloc anymore.

Since this function is a part of the S3 resume code path, we should not release the state when refreshing it within amdgpu_dm_display_resume. Just create it, as it has already been freed.

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 8910a820fbf5..a6424eb1c1a5 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c int amdgpu_dm_display_resume(struct amdgpu_device *adev) · line 695

Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
@@ -691,8 +691,6 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
  	 * disabled. Refresh cached state to match actual current state before
  	 * restoring it.
  	 */
-	WARN_ON(kref_read(&cached_state->context->refcount) > 1);
-	dc_release_state(cached_state->context);
 
  	cached_state->context = dc_create_state();

The new patch is ok but in the existing code

cached_state->context = dc_create_state();

seems to me will cause memory leak since cached_state->context is later overridden inside amdgpu_dm_atomic_check where you allocate and copy construct the current dm/dc states anyway. Seems to me you can drop dc_state allocation in amdgpu_dm_display_resume since you only reference there the drm_atomic_state, later in amdgpu_dm_atomic_check it will be allocated anyway.

patches 9-15 Reviewed-by: Andrey Grodzovsky <[email protected]>

Andrey

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c int amdgpu_dm_display_resume(struct amdgpu_device *adev) · line 696

Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
  	ASSERT(cached_state->context);

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

#21 lore raw

PATCH 16/28 drm/amd/display: Cleanup code that enables freesync

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

This is a follow-up patch to:

Bhawanpreet Lakha Atomic freesync ASSERT fix

Changes:
- Combine to use one iterator
- Use new DRM iterators.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 55 +++++++----------------
 1 file changed, 17 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +17 -38
index a6424eb1c1a5..812a0016869f 100644
@@ -4050,7 +4050,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct amdgpu_crtc *new_crtcs[MAX_STREAMS];
-	struct dc_stream_state *new_stream = NULL;
 	unsigned long flags;
 	bool wait_for_vblank = true;
 	struct drm_connector *connector;
@@ -4145,56 +4144,36 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	 * are removed from freesync module
 	 */
 	if (adev->dm.freesync_module) {
-		for (i = 0; i < new_crtcs_count; i++) {
+		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 			struct amdgpu_dm_connector *aconnector = NULL;
+			struct dm_connector_state *dm_new_con_state = NULL;
+			struct amdgpu_crtc *acrtc = NULL;
 
-			new_crtc_state = drm_atomic_get_new_crtc_state(
-					state, &new_crtcs[i]->base);
 			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+			acrtc = to_amdgpu_crtc(crtc);
 
-			new_stream = dm_new_crtc_state->stream;
 			aconnector =
 				amdgpu_dm_find_first_crtc_matching_connector(
-					state,
-					&new_crtcs[i]->base);
+					state, crtc);
 			if (!aconnector) {
 				DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d "
 					 "skipping freesync init\n",
-					 new_crtcs[i]->crtc_id);
+					 acrtc->crtc_id);
 				continue;
 			}
 
 			mod_freesync_add_stream(adev->dm.freesync_module,
-						new_stream, &aconnector->caps);
-		}
-
-		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
-			struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
-			struct amdgpu_dm_connector *aconnector = NULL;
-			struct dm_connector_state *dm_new_con_state = NULL;
-			struct dm_crtc_state *acrtc_state = NULL;
-
-			new_crtc_state = drm_atomic_get_new_crtc_state(
-					state, &acrtc->base);
-			acrtc_state = to_dm_crtc_state(new_crtc_state);
-
-
-			aconnector =
-				amdgpu_dm_find_first_crtc_matching_connector(
-					state,
-					crtc);
-			if (aconnector) {
-				new_con_state = drm_atomic_get_new_connector_state(
-						state, &aconnector->base);
-				dm_new_con_state = to_dm_connector_state(new_con_state);
-
-				if (new_stream) {
-					mod_freesync_set_user_enable(adev->dm.freesync_module,
-								     &acrtc_state->stream,
-								     1,
-								     &dm_new_con_state->user_enable);
-				}
+						dm_new_crtc_state->stream,
+						&aconnector->caps);
+			new_con_state = drm_atomic_get_new_connector_state(
+					state, &aconnector->base);
+			dm_new_con_state = to_dm_connector_state(new_con_state);
+
+			if (dm_new_crtc_state->stream) {
+				mod_freesync_set_user_enable(adev->dm.freesync_module,
+							     &dm_new_crtc_state->stream,
+							     1,
+							     &dm_new_con_state->user_enable);
 			}
 		}
 	}
Signature · 6 lines
2.14.1

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

PATCH 17/28 drm/amd/display: Move lock to front end program.

In reply to a message not in the archive

From: Yongqiang Sun <[email protected]>

Moved lock and unlock to apply_ctx_to_surface, since all the front end programming is within apply_ctx_to_surface.

---
 drivers/gpu/drm/amd/display/dc/core/dc.c           | 52 +---------------------
 .../amd/display/dc/dce110/dce110_hw_sequencer.c    | 16 +++++++
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c  | 13 +++++-
 3 files changed, 29 insertions(+), 52 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -51
index 0e078c91a674..503817ac0429 100644
@@ -799,7 +799,7 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c
 	struct dc_bios *dcb = dc->ctx->dc_bios;
 	enum dc_status result = DC_ERROR_UNEXPECTED;
 	struct pipe_ctx *pipe;
-	int i, j, k, l;
+	int i, k, l;
 	struct dc_stream_state *dc_streams[MAX_STREAMS] = {0};
 
 	for (i = 0; i < context->stream_count; i++)
@@ -853,15 +853,6 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c
 
 	dc_enable_stereo(dc, context, dc_streams, context->stream_count);
 
-	for (i = 0; i < context->stream_count; i++) {
-		for (j = 0; j < MAX_PIPES; j++) {
-			pipe = &context->res_ctx.pipe_ctx[j];
-
-			if (!pipe->top_pipe && pipe->stream == context->streams[i])
-				dc->hwss.pipe_control_lock(dc, pipe, false);
-		}
-	}
-
 	dc_release_state(dc->current_state);
 
 	dc->current_state = context;
@@ -1265,27 +1256,6 @@ static void commit_planes_for_stream(struct dc *dc,
 		return;
 	}
 
-	/* Lock pipes for provided surfaces, or all active if full update*/
-	for (i = 0; i < surface_count; i++) {
-		struct dc_plane_state *plane_state = srf_updates[i].surface;
-
-		for (j = 0; j < dc->res_pool->pipe_count; j++) {
-			struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
-
-			if (update_type != UPDATE_TYPE_FULL && pipe_ctx->plane_state != plane_state)
-				continue;
-			if (!pipe_ctx->plane_state || pipe_ctx->top_pipe)
-				continue;
-
-			dc->hwss.pipe_control_lock(
-					dc,
-					pipe_ctx,
-					true);
-		}
-		if (update_type == UPDATE_TYPE_FULL)
-			break;
-	}
-
 	/* Full fe update*/
 	for (j = 0; j < dc->res_pool->pipe_count; j++) {
 		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
@@ -1342,26 +1312,6 @@ static void commit_planes_for_stream(struct dc *dc,
 			}
 		}
 	}
-
-	/* Unlock pipes */
-	for (i = dc->res_pool->pipe_count - 1; i >= 0; i--) {
-		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
-
-		for (j = 0; j < surface_count; j++) {
-			if (update_type != UPDATE_TYPE_FULL &&
-			    srf_updates[j].surface != pipe_ctx->plane_state)
-				continue;
-			if (!pipe_ctx->plane_state || pipe_ctx->top_pipe)
-				continue;
-
-			dc->hwss.pipe_control_lock(
-					dc,
-					pipe_ctx,
-					false);
-
-			break;
-		}
-	}
 }
 
 void dc_commit_updates_for_stream(struct dc *dc,
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +16 -0
index e8b8daeeed97..73072650530c 100644
@@ -2886,8 +2886,14 @@ static void dce110_apply_ctx_for_surface(
 
 	be_idx = -1;
 	for (i = 0; i < dc->res_pool->pipe_count; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+		struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
+
 		if (stream == context->res_ctx.pipe_ctx[i].stream) {
 			be_idx = context->res_ctx.pipe_ctx[i].stream_res.tg->inst;
+			if (!pipe_ctx->top_pipe &&
+				(pipe_ctx->plane_state || old_pipe_ctx->plane_state))
+				dc->hwss.pipe_control_lock(dc, pipe_ctx, true);
 			break;
 		}
 	}
@@ -2902,6 +2908,16 @@ static void dce110_apply_ctx_for_surface(
 		program_surface_visibility(dc, pipe_ctx);
 
 	}
+
+	for (i = 0; i < dc->res_pool->pipe_count; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+		struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
+
+		if ((stream == pipe_ctx->stream) &&
+			(!pipe_ctx->top_pipe) &&
+			(pipe_ctx->plane_state || old_pipe_ctx->plane_state))
+			dc->hwss.pipe_control_lock(dc, pipe_ctx, false);
+	}
 }
 
 static void dce110_power_down_fe(struct dc *dc, int fe_idx)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +12 -1
index 63c2f5266142..0d1f0e2a4350 100644
@@ -2550,6 +2550,11 @@ static void dcn10_apply_ctx_for_surface(
 		if (!pipe_ctx->plane_state && !old_pipe_ctx->plane_state)
 			continue;
 
+		if (pipe_ctx->stream_res.tg &&
+			pipe_ctx->stream_res.tg->inst == be_idx &&
+			!pipe_ctx->top_pipe)
+			pipe_ctx->stream_res.tg->funcs->lock(pipe_ctx->stream_res.tg);
+
 		/*
 		 * Powergate reused pipes that are not powergated
 		 * fairly hacky right now, using opp_id as indicator
@@ -2605,13 +2610,19 @@ static void dcn10_apply_ctx_for_surface(
 
 	for (i = 0; i < dc->res_pool->pipe_count; i++) {
 		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+		struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
 
 		if (pipe_ctx->stream != stream)
 			continue;
 
 		/* looking for top pipe to program */
-		if (!pipe_ctx->top_pipe)
+		if (!pipe_ctx->top_pipe) {
 			program_all_pipe_in_tree(dc, pipe_ctx, context);
+			if (pipe_ctx->stream_res.tg &&
+				pipe_ctx->stream_res.tg->inst == be_idx &&
+				(pipe_ctx->plane_state || old_pipe_ctx->plane_state))
+				pipe_ctx->stream_res.tg->funcs->unlock(pipe_ctx->stream_res.tg);
+		}
 	}
 
 	dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_CALCS,
Signature · 6 lines
2.14.1

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

PATCH 18/28 drm/amd/display: Check cursor address before program.

In reply to a message not in the archive

From: Yongqiang Sun <[email protected]>

Program cursor attributes during set mode is only needed in case of pipe slipt, bottom pipe should be programmed same as top pipe. Need to program if address is 0.

---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +2 -1
index 0d1f0e2a4350..c82d667c35a3 100644
@@ -2436,7 +2436,8 @@ static void program_all_pipe_in_tree(
 		/* TODO: this is a hack w/a for switching from mpo to pipe split */
 		dc_stream_set_cursor_position(pipe_ctx->stream, &position);
 
-		dc_stream_set_cursor_attributes(pipe_ctx->stream,
+		if (pipe_ctx->stream->cursor_attributes.address.quad_part != 0)
+			dc_stream_set_cursor_attributes(pipe_ctx->stream,
 				&pipe_ctx->stream->cursor_attributes);
 
 		if (cur_pipe_ctx->plane_state != pipe_ctx->plane_state) {
Signature · 6 lines
2.14.1

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

PATCH 19/28 drm/amd/display: Adding DCN1 registers

In reply to a message not in the archive

From: Mikita Lipski <[email protected]>

Registers added to definition list that are required for multi display synchronization

---
 .../amd/display/dc/dcn10/dcn10_timing_generator.h  | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_timing_generator.h +30 -3
index 7d4818d7aa31..395820606013 100644
@@ -72,7 +72,10 @@
 	SRI(OPTC_INPUT_GLOBAL_CONTROL, ODM, inst),\
 	SRI(OPPBUF_CONTROL, OPPBUF, inst),\
 	SRI(OPPBUF_3D_PARAMETERS_0, OPPBUF, inst),\
-	SRI(CONTROL, VTG, inst)
+	SRI(CONTROL, VTG, inst),\
+	SRI(OTG_VERT_SYNC_CONTROL, OTG, inst),\
+	SRI(OTG_MASTER_UPDATE_MODE, OTG, inst),\
+	SRI(OTG_GSL_CONTROL, OTG, inst)
 
 #define TG_COMMON_REG_LIST_DCN1_0(inst) \
 	TG_COMMON_REG_LIST_DCN(inst),\
@@ -82,6 +85,9 @@
 
 
 struct dcn_tg_registers {
+	uint32_t OTG_VERT_SYNC_CONTROL;
+	uint32_t OTG_MASTER_UPDATE_MODE;
+	uint32_t OTG_GSL_CONTROL;
 	uint32_t OTG_VSTARTUP_PARAM;
 	uint32_t OTG_VUPDATE_PARAM;
 	uint32_t OTG_VREADY_PARAM;
@@ -208,7 +214,18 @@ struct dcn_tg_registers {
 	SF(OPPBUF0_OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE1_SIZE, mask_sh),\
 	SF(VTG0_CONTROL, VTG0_ENABLE, mask_sh),\
 	SF(VTG0_CONTROL, VTG0_FP2, mask_sh),\
-	SF(VTG0_CONTROL, VTG0_VCOUNT_INIT, mask_sh)
+	SF(VTG0_CONTROL, VTG0_VCOUNT_INIT, mask_sh),\
+	SF(OTG0_OTG_VERT_SYNC_CONTROL, OTG_FORCE_VSYNC_NEXT_LINE_OCCURRED, mask_sh),\
+	SF(OTG0_OTG_VERT_SYNC_CONTROL, OTG_FORCE_VSYNC_NEXT_LINE_CLEAR, mask_sh),\
+	SF(OTG0_OTG_VERT_SYNC_CONTROL, OTG_AUTO_FORCE_VSYNC_MODE, mask_sh),\
+	SF(OTG0_OTG_MASTER_UPDATE_MODE, MASTER_UPDATE_INTERLACED_MODE, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL0_EN, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL1_EN, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL2_EN, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL_MASTER_EN, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL_FORCE_DELAY, mask_sh),\
+	SF(OTG0_OTG_GSL_CONTROL, OTG_GSL_CHECK_ALL_FIELDS, mask_sh)
+
 
 #define TG_COMMON_MASK_SH_LIST_DCN1_0(mask_sh)\
 	TG_COMMON_MASK_SH_LIST_DCN(mask_sh),\
@@ -317,7 +334,17 @@ struct dcn_tg_registers {
 	type OPPBUF_3D_VACT_SPACE1_SIZE;\
 	type VTG0_ENABLE;\
 	type VTG0_FP2;\
-	type VTG0_VCOUNT_INIT;
+	type VTG0_VCOUNT_INIT;\
+	type OTG_FORCE_VSYNC_NEXT_LINE_OCCURRED;\
+	type OTG_FORCE_VSYNC_NEXT_LINE_CLEAR;\
+	type OTG_AUTO_FORCE_VSYNC_MODE;\
+	type MASTER_UPDATE_INTERLACED_MODE;\
+	type OTG_GSL0_EN;\
+	type OTG_GSL1_EN;\
+	type OTG_GSL2_EN;\
+	type OTG_GSL_MASTER_EN;\
+	type OTG_GSL_FORCE_DELAY;\
+	type OTG_GSL_CHECK_ALL_FIELDS;
 
 struct dcn_tg_shift {
 	TG_REG_FIELD_LIST(uint8_t)
Signature · 6 lines
2.14.1

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

PATCH 20/28 drm/amd/display: Fix no display on Fiji

In reply to a message not in the archive

From: Jerry Zuo <[email protected]>

Allocate memory for the second pipe allocate_mem_input() needs to be done prior to program pipe front end. It shows sensitive to Fiji. Failure to do so will cause error in allocate memory allocate_mem_input() on the second connected display.

---
 .../drm/amd/display/dc/dce110/dce110_hw_sequencer.c   | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +9 -10
index 73072650530c..df6da5428e74 100644
@@ -1377,16 +1377,6 @@ static enum dc_status apply_single_controller_ctx_to_hw(
 		program_scaler(dc, pipe_ctx);
 	}
 
-	/* mst support - use total stream count */
-	if (pipe_ctx->plane_res.mi != NULL) {
-		pipe_ctx->plane_res.mi->funcs->allocate_mem_input(
-				pipe_ctx->plane_res.mi,
-				stream->timing.h_total,
-				stream->timing.v_total,
-				stream->timing.pix_clk_khz,
-				context->stream_count);
-	}
-
 	pipe_ctx->stream->sink->link->psr_enabled = false;
 
 	return DC_OK;
@@ -2904,6 +2894,15 @@ static void dce110_apply_ctx_for_surface(
 		if (pipe_ctx->stream != stream)
 			continue;
 
+		/* Need to allocate mem before program front end for Fiji */
+		if (pipe_ctx->plane_res.mi != NULL)
+			pipe_ctx->plane_res.mi->funcs->allocate_mem_input(
+					pipe_ctx->plane_res.mi,
+					pipe_ctx->stream->timing.h_total,
+					pipe_ctx->stream->timing.v_total,
+					pipe_ctx->stream->timing.pix_clk_khz,
+					context->stream_count);
+
 		dce110_program_front_end_for_pipe(dc, pipe_ctx);
 		program_surface_visibility(dc, pipe_ctx);
 
Signature · 6 lines
2.14.1

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

PATCH 21/28 drm/amd/display: Cleanup some fail labels in dcn10_resource

In reply to a message not in the archive
---
 .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c  | 37 ++++++++--------------
 1 file changed, 13 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +13 -24
index 776caf804b95..9d85d265c2c7 100644
@@ -1275,7 +1275,7 @@ static bool construct(
 		if (pool->base.clock_sources[i] == NULL) {
 			dm_error("DC: failed to create clock sources!\n");
 			BREAK_TO_DEBUGGER();
-			goto clock_source_create_fail;
+			goto fail;
 		}
 	}
 
@@ -1284,7 +1284,7 @@ static bool construct(
 		if (pool->base.display_clock == NULL) {
 			dm_error("DC: failed to create display clock!\n");
 			BREAK_TO_DEBUGGER();
-			goto disp_clk_create_fail;
+			goto fail;
 		}
 	}
 
@@ -1295,7 +1295,7 @@ static bool construct(
 	if (pool->base.dmcu == NULL) {
 		dm_error("DC: failed to create dmcu!\n");
 		BREAK_TO_DEBUGGER();
-		goto res_create_fail;
+		goto fail;
 	}
 
 	pool->base.abm = dce_abm_create(ctx,
@@ -1305,7 +1305,7 @@ static bool construct(
 	if (pool->base.abm == NULL) {
 		dm_error("DC: failed to create abm!\n");
 		BREAK_TO_DEBUGGER();
-		goto res_create_fail;
+		goto fail;
 	}
 
 	dml_init_instance(&dc->dml, DML_PROJECT_RAVEN1);
@@ -1345,13 +1345,11 @@ static bool construct(
 	}
 
 	{
-	#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
 		struct irq_service_init_data init_data;
 		init_data.ctx = dc->ctx;
 		pool->base.irqs = dal_irq_service_dcn10_create(&init_data);
 		if (!pool->base.irqs)
-			goto irqs_create_fail;
-	#endif
+			goto fail;
 	}
 
 	/* index to valid pipe resource  */
@@ -1369,7 +1367,7 @@ static bool construct(
 			BREAK_TO_DEBUGGER();
 			dm_error(
 				"DC: failed to create memory input!\n");
-			goto mi_create_fail;
+			goto fail;
 		}
 
 		pool->base.ipps[j] = dcn10_ipp_create(ctx, i);
@@ -1377,7 +1375,7 @@ static bool construct(
 			BREAK_TO_DEBUGGER();
 			dm_error(
 				"DC: failed to create input pixel processor!\n");
-			goto ipp_create_fail;
+			goto fail;
 		}
 
 		pool->base.dpps[j] = dcn10_dpp_create(ctx, i);
@@ -1385,7 +1383,7 @@ static bool construct(
 			BREAK_TO_DEBUGGER();
 			dm_error(
 				"DC: failed to create dpp!\n");
-			goto dpp_create_fail;
+			goto fail;
 		}
 
 		pool->base.opps[j] = dcn10_opp_create(ctx, i);
@@ -1393,7 +1391,7 @@ static bool construct(
 			BREAK_TO_DEBUGGER();
 			dm_error(
 				"DC: failed to create output pixel processor!\n");
-			goto opp_create_fail;
+			goto fail;
 		}
 
 		pool->base.timing_generators[j] = dcn10_timing_generator_create(
@@ -1401,7 +1399,7 @@ static bool construct(
 		if (pool->base.timing_generators[j] == NULL) {
 			BREAK_TO_DEBUGGER();
 			dm_error("DC: failed to create tg!\n");
-			goto otg_create_fail;
+			goto fail;
 		}
 		/* check next valid pipe */
 		j++;
@@ -1420,13 +1418,13 @@ static bool construct(
 	if (pool->base.mpc == NULL) {
 		BREAK_TO_DEBUGGER();
 		dm_error("DC: failed to create mpc!\n");
-		goto mpc_create_fail;
+		goto fail;
 	}
 
 	if (!resource_construct(num_virtual_links, dc, &pool->base,
 			(!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
 			&res_create_funcs : &res_create_maximus_funcs)))
-			goto res_create_fail;
+			goto fail;
 
 	dcn10_hw_sequencer_construct(dc);
 	dc->caps.max_planes =  pool->base.pipe_count;
@@ -1435,16 +1433,7 @@ static bool construct(
 
 	return true;
 
-disp_clk_create_fail:
-mpc_create_fail:
-otg_create_fail:
-opp_create_fail:
-dpp_create_fail:
-ipp_create_fail:
-mi_create_fail:
-irqs_create_fail:
-res_create_fail:
-clock_source_create_fail:
+fail:
 
 	destruct(pool);
 
Signature · 6 lines
2.14.1

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

PATCH 22/28 drm/amd/display: Clean some unneeded defines from ddc_service_types.h

In reply to a message not in the archive

Remove defines we no longer need

---
 .../drm/amd/display/include/ddc_service_types.h    | 33 ----------------------
 1 file changed, 33 deletions(-)
drivers/gpu/drm/amd/display/include/ddc_service_types.h +0 -33
index 0ff2a899b8f7..019e7a095ea1 100644
@@ -27,12 +27,8 @@
 
 #define DP_BRANCH_DEVICE_ID_1 0x0010FA
 #define DP_BRANCH_DEVICE_ID_2 0x0022B9
-#define DP_SINK_DEVICE_ID_1 0x4CE000
 #define DP_BRANCH_DEVICE_ID_3 0x00001A
 #define DP_BRANCH_DEVICE_ID_4 0x0080e1
-#define DP_BRANCH_DEVICE_ID_5 0x006037
-#define DP_SINK_DEVICE_ID_2 0x001CF8
-
 
 enum ddc_result {
 	DDC_RESULT_UNKNOWN = 0,
@@ -115,40 +111,11 @@ struct av_sync_data {
 	uint8_t aud_del_ins3;/* DPCD 0002Dh */
 };
 
-/*DP to VGA converter*/
-static const uint8_t DP_VGA_CONVERTER_ID_1[] = "mVGAa";
-/*DP to Dual link DVI converter*/
-static const uint8_t DP_DVI_CONVERTER_ID_1[] = "m2DVIa";
 /*Travis*/
 static const uint8_t DP_VGA_LVDS_CONVERTER_ID_2[] = "sivarT";
 /*Nutmeg*/
 static const uint8_t DP_VGA_LVDS_CONVERTER_ID_3[] = "dnomlA";
-/*DP to VGA converter*/
-static const uint8_t DP_VGA_CONVERTER_ID_4[] = "DpVga";
 /*DP to Dual link DVI converter*/
 static const uint8_t DP_DVI_CONVERTER_ID_4[] = "m2DVIa";
-/*DP to Dual link DVI converter 2*/
-static const uint8_t DP_DVI_CONVERTER_ID_42[] = "v2DVIa";
-
-static const uint8_t DP_SINK_DEV_STRING_ID2_REV0[] = "\0\0\0\0\0\0";
-
-/* Identifies second generation PSR TCON from Parade: Device ID string:
- * yy-xx-**-**-**-**
- */
-/* xx - Hw ID high byte */
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_HIGH_BYTE =
-	0x06;
-
-/* yy - HW ID low byte, the same silicon has several package/feature flavors */
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_LOW_BYTE1 =
-	0x61;
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_LOW_BYTE2 =
-	0x62;
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_LOW_BYTE3 =
-	0x63;
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_LOW_BYTE4 =
-	0x72;
-static const uint32_t DP_SINK_DEV_STRING_ID2_REV1_HW_ID_LOW_BYTE5 =
-	0x73;
 
 #endif /* __DAL_DDC_SERVICE_TYPES_H__ */
Signature · 6 lines
2.14.1

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

PATCH 23/28 drm/amd/display: cleaning up hubp for dcn

In reply to a message not in the archive

From: Yue Hin Lau <[email protected]>

removing duplicate functions, renaming struct mi_regs, etc.

---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c  |  16 +-
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h  | 345 +++++++++++----------
 .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c  |  24 +-
 3 files changed, 193 insertions(+), 192 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +8 -8
index b13dee64e0ce..a19fac70b056 100644
@@ -29,14 +29,14 @@
 #include "dcn10_hubp.h"
 
 #define REG(reg)\
-	hubp1->mi_regs->reg
+	hubp1->hubp_regs->reg
 
 #define CTX \
 	hubp1->base.ctx
 
 #undef FN
 #define FN(reg_name, field_name) \
-	hubp1->mi_shift->field_name, hubp1->mi_mask->field_name
+	hubp1->hubp_shift->field_name, hubp1->hubp_mask->field_name
 
 void hubp1_set_blank(struct hubp *hubp, bool blank)
 {
@@ -943,15 +943,15 @@ void dcn10_hubp_construct(
 	struct dcn10_hubp *hubp1,
 	struct dc_context *ctx,
 	uint32_t inst,
-	const struct dcn_mi_registers *mi_regs,
-	const struct dcn_mi_shift *mi_shift,
-	const struct dcn_mi_mask *mi_mask)
+	const struct dcn_mi_registers *hubp_regs,
+	const struct dcn_mi_shift *hubp_shift,
+	const struct dcn_mi_mask *hubp_mask)
 {
 	hubp1->base.funcs = &dcn10_hubp_funcs;
 	hubp1->base.ctx = ctx;
-	hubp1->mi_regs = mi_regs;
-	hubp1->mi_shift = mi_shift;
-	hubp1->mi_mask = mi_mask;
+	hubp1->hubp_regs = hubp_regs;
+	hubp1->hubp_shift = hubp_shift;
+	hubp1->hubp_mask = hubp_mask;
 	hubp1->base.inst = inst;
 	hubp1->base.opp_id = 0xf;
 	hubp1->base.mpcc_id = 0xf;
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +173 -172

384 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +12 -12
index 9d85d265c2c7..c40b9e70d8a7 100644
@@ -367,25 +367,25 @@ static const struct bios_registers bios_regs = {
 		NBIO_SR(BIOS_SCRATCH_6)
 };
 
-#define mi_regs(id)\
+#define hubp_regs(id)\
 [id] = {\
-	MI_REG_LIST_DCN10(id)\
+	HUBP_REG_LIST_DCN10(id)\
 }
 
 
-static const struct dcn_mi_registers mi_regs[] = {
-	mi_regs(0),
-	mi_regs(1),
-	mi_regs(2),
-	mi_regs(3),
+static const struct dcn_mi_registers hubp_regs[] = {
+	hubp_regs(0),
+	hubp_regs(1),
+	hubp_regs(2),
+	hubp_regs(3),
 };
 
-static const struct dcn_mi_shift mi_shift = {
-		MI_MASK_SH_LIST_DCN10(__SHIFT)
+static const struct dcn_mi_shift hubp_shift = {
+		HUBP_MASK_SH_LIST_DCN10(__SHIFT)
 };
 
-static const struct dcn_mi_mask mi_mask = {
-		MI_MASK_SH_LIST_DCN10(_MASK)
+static const struct dcn_mi_mask hubp_mask = {
+		HUBP_MASK_SH_LIST_DCN10(_MASK)
 };
 
 #define clk_src_regs(index, pllid)\
@@ -770,7 +770,7 @@ static struct hubp *dcn10_hubp_create(
 		return NULL;
 
 	dcn10_hubp_construct(hubp1, ctx, inst,
-			     &mi_regs[inst], &mi_shift, &mi_mask);
+			     &hubp_regs[inst], &hubp_shift, &hubp_mask);
 	return &hubp1->base;
 }
 
Signature · 6 lines
2.14.1

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

PATCH 24/28 drm/amd/display: Explicit casting for grph object ids

In reply to a message not in the archive

C++ compilers don't like the implicit conversion

---
 drivers/gpu/drm/amd/display/include/grph_object_id.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/include/grph_object_id.h +6 -6
index 5eb2b4dc7b9c..03a7a9ca95ea 100644
@@ -248,7 +248,7 @@ static inline enum controller_id dal_graphics_object_id_get_controller_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_CONTROLLER)
-		return id.id;
+		return (enum controller_id) id.id;
 	return CONTROLLER_ID_UNDEFINED;
 }
 
@@ -256,7 +256,7 @@ static inline enum clock_source_id dal_graphics_object_id_get_clock_source_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_CLOCK_SOURCE)
-		return id.id;
+		return (enum clock_source_id) id.id;
 	return CLOCK_SOURCE_ID_UNDEFINED;
 }
 
@@ -264,7 +264,7 @@ static inline enum encoder_id dal_graphics_object_id_get_encoder_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_ENCODER)
-		return id.id;
+		return (enum encoder_id) id.id;
 	return ENCODER_ID_UNKNOWN;
 }
 
@@ -272,7 +272,7 @@ static inline enum connector_id dal_graphics_object_id_get_connector_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_CONNECTOR)
-		return id.id;
+		return (enum connector_id) id.id;
 	return CONNECTOR_ID_UNKNOWN;
 }
 
@@ -280,7 +280,7 @@ static inline enum audio_id dal_graphics_object_id_get_audio_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_AUDIO)
-		return id.id;
+		return (enum audio_id) id.id;
 	return AUDIO_ID_UNKNOWN;
 }
 
@@ -288,7 +288,7 @@ static inline enum engine_id dal_graphics_object_id_get_engine_id(
 	struct graphics_object_id id)
 {
 	if (id.type == OBJECT_TYPE_ENGINE)
-		return id.id;
+		return (enum engine_id) id.id;
 	return ENGINE_ID_UNKNOWN;
 }
 #endif
Signature · 6 lines
2.14.1

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

PATCH 25/28 drm/amd/display: Should disable when new stream is null

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

core_link_disable_stream should be called when the new stream is null (i.e. want to disable). Modify the if condition to reflect that.

---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +4 -2
index df6da5428e74..6c220a213ff2 100644
@@ -1875,8 +1875,10 @@ static void dce110_reset_hw_ctx_wrap(
 				pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
 			struct clock_source *old_clk = pipe_ctx_old->clock_source;
 
-			/* disable already, no need to disable again */
-			if (pipe_ctx->stream && !pipe_ctx->stream->dpms_off)
+			/* Disable if new stream is null. O/w, if stream is
+			 * disabled already, no need to disable again.
+			 */
+			if (!pipe_ctx->stream || !pipe_ctx->stream->dpms_off)
 				core_link_disable_stream(pipe_ctx_old, FREE_ACQUIRED_RESOURCE);
 
 			pipe_ctx_old->stream_res.tg->funcs->set_blank(pipe_ctx_old->stream_res.tg, true);
Signature · 6 lines
2.14.1

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

PATCH 26/28 drm/amd/display: Set cursor position as per address.

In reply to a message not in the archive

From: Yongqiang Sun <[email protected]>

In case of pipe split, cursor position should also be programmed as per cursor address.

---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +4 -3
index c82d667c35a3..d23cd1618623 100644
@@ -2414,7 +2414,6 @@ static void program_all_pipe_in_tree(
 	}
 
 	if (pipe_ctx->plane_state != NULL) {
-		struct dc_cursor_position position = { 0 };
 		struct pipe_ctx *cur_pipe_ctx =
 				&dc->current_state->res_ctx.pipe_ctx[pipe_ctx->pipe_idx];
 
@@ -2434,11 +2433,13 @@ static void program_all_pipe_in_tree(
 		update_dchubp_dpp(dc, pipe_ctx, context);
 
 		/* TODO: this is a hack w/a for switching from mpo to pipe split */
-		dc_stream_set_cursor_position(pipe_ctx->stream, &position);
+		if (pipe_ctx->stream->cursor_attributes.address.quad_part != 0) {
+			struct dc_cursor_position position = { 0 };
 
-		if (pipe_ctx->stream->cursor_attributes.address.quad_part != 0)
+			dc_stream_set_cursor_position(pipe_ctx->stream, &position);
 			dc_stream_set_cursor_attributes(pipe_ctx->stream,
 				&pipe_ctx->stream->cursor_attributes);
+		}
 
 		if (cur_pipe_ctx->plane_state != pipe_ctx->plane_state) {
 			dc->hwss.set_input_transfer_func(
Signature · 6 lines
2.14.1

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

PATCH 27/28 drm/amd/display: DMCU FW loading from PSP

In reply to a message not in the archive

From: Anthony Koo <[email protected]>

Update the programming sequence to allow DMCU firmware to be loaded by PSP. This code detects whether the firmware is loaded and does a check to verify the expected interface version and checks for correct response from micro controller.

Added registry key method to allow force loading of firmware from kernel mode driver for test purposes. This is old method of firmware loading without PSP.

Moved some init sequences into dc/dmcu.

Changed loading sequence to initialize IRAM after firmware completely loaded. Firmware will now disable features that use IRAM until initialized.

---
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c      | 176 ++++++++++++++++++++-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h      |  12 +-
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c  |   5 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h       |  16 ++
 4 files changed, 202 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c +170 -6
index 3691c7498d08..b60524add047 100644
@@ -49,9 +49,18 @@
 #define PSR_EXIT 0x21
 #define PSR_SET 0x23
 #define PSR_SET_WAITLOOP 0x31
+#define MCP_INIT_DMCU 0x88
+#define MCP_INIT_IRAM 0x89
+#define MCP_DMCU_VERSION 0x90
 #define MASTER_COMM_CNTL_REG__MASTER_COMM_INTERRUPT_MASK   0x00000001L
 unsigned int cached_wait_loop_number = 0;
 
+static bool dce_dmcu_init(struct dmcu *dmcu)
+{
+	// Do nothing
+	return true;
+}
+
 bool dce_dmcu_load_iram(struct dmcu *dmcu,
 		unsigned int start_offset,
 		const char *src,
@@ -84,7 +93,7 @@ static void dce_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)
 {
 	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
 
-	uint32_t psrStateOffset = 0xf0;
+	uint32_t psr_state_offset = 0xf0;
 
 	/* Enable write access to IRAM */
 	REG_UPDATE(DMCU_RAM_ACCESS_CTRL, IRAM_HOST_ACCESS_EN, 1);
@@ -92,7 +101,7 @@ static void dce_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)
 	REG_WAIT(DCI_MEM_PWR_STATUS, DMCU_IRAM_MEM_PWR_STATE, 0, 2, 10);
 
 	/* Write address to IRAM_RD_ADDR in DMCU_IRAM_RD_CTRL */
-	REG_WRITE(DMCU_IRAM_RD_CTRL, psrStateOffset);
+	REG_WRITE(DMCU_IRAM_RD_CTRL, psr_state_offset);
 
 	/* Read data from IRAM_RD_DATA in DMCU_IRAM_RD_DATA*/
 	*psr_state = REG_READ(DMCU_IRAM_RD_DATA);
@@ -286,7 +295,128 @@ static void dce_get_psr_wait_loop(unsigned int *psr_wait_loop_number)
 }
 
 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
-bool dcn10_dmcu_load_iram(struct dmcu *dmcu,
+static void dcn10_get_dmcu_state(struct dmcu *dmcu)
+{
+	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
+	uint32_t dmcu_state_offset = 0xf6;
+
+	/* Enable write access to IRAM */
+	REG_UPDATE_2(DMCU_RAM_ACCESS_CTRL,
+			IRAM_HOST_ACCESS_EN, 1,
+			IRAM_RD_ADDR_AUTO_INC, 1);
+
+	REG_WAIT(DMU_MEM_PWR_CNTL, DMCU_IRAM_MEM_PWR_STATE, 0, 2, 10);
+
+	/* Write address to IRAM_RD_ADDR in DMCU_IRAM_RD_CTRL */
+	REG_WRITE(DMCU_IRAM_RD_CTRL, dmcu_state_offset);
+
+	/* Read data from IRAM_RD_DATA in DMCU_IRAM_RD_DATA*/
+	dmcu->dmcu_state = REG_READ(DMCU_IRAM_RD_DATA);
+
+	/* Disable write access to IRAM to allow dynamic sleep state */
+	REG_UPDATE_2(DMCU_RAM_ACCESS_CTRL,
+			IRAM_HOST_ACCESS_EN, 0,
+			IRAM_RD_ADDR_AUTO_INC, 0);
+}
+
+static void dcn10_get_dmcu_version(struct dmcu *dmcu)
+{
+	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
+	uint32_t dmcu_version_offset = 0xf1;
+
+	/* Clear scratch */
+	REG_WRITE(DC_DMCU_SCRATCH, 0);
+
+	/* Enable write access to IRAM */
+	REG_UPDATE_2(DMCU_RAM_ACCESS_CTRL,
+			IRAM_HOST_ACCESS_EN, 1,
+			IRAM_RD_ADDR_AUTO_INC, 1);
+
+	REG_WAIT(DMU_MEM_PWR_CNTL, DMCU_IRAM_MEM_PWR_STATE, 0, 2, 10);
+
+	/* Write address to IRAM_RD_ADDR and read from DATA register */
+	REG_WRITE(DMCU_IRAM_RD_CTRL, dmcu_version_offset);
+	dmcu->dmcu_version.interface_version = REG_READ(DMCU_IRAM_RD_DATA);
+	dmcu->dmcu_version.year = ((REG_READ(DMCU_IRAM_RD_DATA) << 8) |
+						REG_READ(DMCU_IRAM_RD_DATA));
+	dmcu->dmcu_version.month = REG_READ(DMCU_IRAM_RD_DATA);
+	dmcu->dmcu_version.day = REG_READ(DMCU_IRAM_RD_DATA);
+
+	/* Disable write access to IRAM to allow dynamic sleep state */
+	REG_UPDATE_2(DMCU_RAM_ACCESS_CTRL,
+			IRAM_HOST_ACCESS_EN, 0,
+			IRAM_RD_ADDR_AUTO_INC, 0);
+
+	/* Send MCP command message to DMCU to get version reply from FW.
+	 * We expect this version should match the one in IRAM, otherwise
+	 * something is wrong with DMCU and we should fail and disable UC.
+	 */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
+	/* Set command to get DMCU version from microcontroller */
+	REG_UPDATE(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0,
+			MCP_DMCU_VERSION);
+
+	/* Notify microcontroller of new command */
+	REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1);
+
+	/* Ensure command has been executed before continuing */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
+	/* Somehow version does not match, so fail and return version 0 */
+	if (dmcu->dmcu_version.interface_version != REG_READ(DC_DMCU_SCRATCH))
+		dmcu->dmcu_version.interface_version = 0;
+}
+
+static bool dcn10_dmcu_init(struct dmcu *dmcu)
+{
+	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
+
+	/* DMCU FW should populate the scratch register if running */
+	if (REG_READ(DC_DMCU_SCRATCH) == 0)
+		return false;
+
+	/* Check state is uninitialized */
+	dcn10_get_dmcu_state(dmcu);
+
+	/* If microcontroller is already initialized, do nothing */
+	if (dmcu->dmcu_state == DMCU_RUNNING)
+		return true;
+
+	/* Retrieve and cache the DMCU firmware version. */
+	dcn10_get_dmcu_version(dmcu);
+
+	/* Check interface version to confirm firmware is loaded and running */
+	if (dmcu->dmcu_version.interface_version == 0)
+		return false;
+
+	/* Wait until microcontroller is ready to process interrupt */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
+	/* Set initialized ramping boundary value */
+	REG_WRITE(MASTER_COMM_DATA_REG1, 0xFFFF);
+
+	/* Set command to initialize microcontroller */
+	REG_UPDATE(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0,
+			MCP_INIT_DMCU);
+
+	/* Notify microcontroller of new command */
+	REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1);
+
+	/* Ensure command has been executed before continuing */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
+	// Check state is initialized
+	dcn10_get_dmcu_state(dmcu);
+
+	// If microcontroller is not in running state, fail
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return false;
+
+	return true;
+}
+
+static bool dcn10_dmcu_load_iram(struct dmcu *dmcu,
 		unsigned int start_offset,
 		const char *src,
 		unsigned int bytes)
@@ -294,7 +424,9 @@ bool dcn10_dmcu_load_iram(struct dmcu *dmcu,
 	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
 	unsigned int count = 0;
 
-	REG_UPDATE(DMCU_CTRL, DMCU_ENABLE, 1);
+	/* If microcontroller is not running, do nothing */
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return false;
 
 	/* Enable write access to IRAM */
 	REG_UPDATE_2(DMCU_RAM_ACCESS_CTRL,
@@ -313,6 +445,19 @@ bool dcn10_dmcu_load_iram(struct dmcu *dmcu,
 			IRAM_HOST_ACCESS_EN, 0,
 			IRAM_WR_ADDR_AUTO_INC, 0);
 
+	/* Wait until microcontroller is ready to process interrupt */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
+	/* Set command to signal IRAM is loaded and to initialize IRAM */
+	REG_UPDATE(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0,
+			MCP_INIT_IRAM);
+
+	/* Notify microcontroller of new command */
+	REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1);
+
+	/* Ensure command has been executed before continuing */
+	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 100, 800);
+
 	return true;
 }
 
@@ -320,7 +465,11 @@ static void dcn10_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)
 {
 	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
 
-	uint32_t psrStateOffset = 0xf0;
+	uint32_t psr_state_offset = 0xf0;
+
+	/* If microcontroller is not running, do nothing */
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return;
 
 	/* Enable write access to IRAM */
 	REG_UPDATE(DMCU_RAM_ACCESS_CTRL, IRAM_HOST_ACCESS_EN, 1);
@@ -328,7 +477,7 @@ static void dcn10_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)
 	REG_WAIT(DMU_MEM_PWR_CNTL, DMCU_IRAM_MEM_PWR_STATE, 0, 2, 10);
 
 	/* Write address to IRAM_RD_ADDR in DMCU_IRAM_RD_CTRL */
-	REG_WRITE(DMCU_IRAM_RD_CTRL, psrStateOffset);
+	REG_WRITE(DMCU_IRAM_RD_CTRL, psr_state_offset);
 
 	/* Read data from IRAM_RD_DATA in DMCU_IRAM_RD_DATA*/
 	*psr_state = REG_READ(DMCU_IRAM_RD_DATA);
@@ -348,6 +497,10 @@ static void dcn10_dmcu_set_psr_enable(struct dmcu *dmcu, bool enable, bool wait)
 	unsigned int retryCount;
 	uint32_t psr_state = 0;
 
+	/* If microcontroller is not running, do nothing */
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return;
+
 	/* waitDMCUReadyForCmd */
 	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0,
 				dmcu_wait_reg_ready_interval,
@@ -399,6 +552,10 @@ static void dcn10_dmcu_setup_psr(struct dmcu *dmcu,
 	union dce_dmcu_psr_config_data_reg2 masterCmdData2;
 	union dce_dmcu_psr_config_data_reg3 masterCmdData3;
 
+	/* If microcontroller is not running, do nothing */
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return;
+
 	link->link_enc->funcs->psr_program_dp_dphy_fast_training(link->link_enc,
 			psr_context->psrExitLinkTrainingRequired);
 
@@ -505,6 +662,11 @@ static void dcn10_psr_wait_loop(
 {
 	struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
 	union dce_dmcu_psr_config_data_wait_loop_reg1 masterCmdData1;
+
+	/* If microcontroller is not running, do nothing */
+	if (dmcu->dmcu_state != DMCU_RUNNING)
+		return;
+
 	if (wait_loop_number != 0) {
 	/* waitDMCUReadyForCmd */
 	REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 1, 10000);
@@ -531,6 +693,7 @@ static void dcn10_get_psr_wait_loop(unsigned int *psr_wait_loop_number)
 #endif
 
 static const struct dmcu_funcs dce_funcs = {
+	.dmcu_init = dce_dmcu_init,
 	.load_iram = dce_dmcu_load_iram,
 	.set_psr_enable = dce_dmcu_set_psr_enable,
 	.setup_psr = dce_dmcu_setup_psr,
@@ -541,6 +704,7 @@ static const struct dmcu_funcs dce_funcs = {
 
 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
 static const struct dmcu_funcs dcn10_funcs = {
+	.dmcu_init = dcn10_dmcu_init,
 	.load_iram = dcn10_dmcu_load_iram,
 	.set_psr_enable = dcn10_dmcu_set_psr_enable,
 	.setup_psr = dcn10_dmcu_setup_psr,
drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h +11 -1
index b85f53c2f6f8..4c25e2dd28f8 100644
@@ -31,6 +31,7 @@
 
 #define DMCU_COMMON_REG_LIST_DCE_BASE() \
 	SR(DMCU_CTRL), \
+	SR(DMCU_STATUS), \
 	SR(DMCU_RAM_ACCESS_CTRL), \
 	SR(DMCU_IRAM_WR_CTRL), \
 	SR(DMCU_IRAM_WR_DATA), \
@@ -42,7 +43,8 @@
 	SR(DMCU_IRAM_RD_CTRL), \
 	SR(DMCU_IRAM_RD_DATA), \
 	SR(DMCU_INTERRUPT_TO_UC_EN_MASK), \
-	SR(SMU_INTERRUPT_CONTROL)
+	SR(SMU_INTERRUPT_CONTROL), \
+	SR(DC_DMCU_SCRATCH)
 
 #define DMCU_DCE110_COMMON_REG_LIST() \
 	DMCU_COMMON_REG_LIST_DCE_BASE(), \
@@ -58,10 +60,14 @@
 #define DMCU_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
 	DMCU_SF(DMCU_CTRL, \
 			DMCU_ENABLE, mask_sh), \
+	DMCU_SF(DMCU_STATUS, \
+			UC_IN_STOP_MODE, mask_sh), \
 	DMCU_SF(DMCU_RAM_ACCESS_CTRL, \
 			IRAM_HOST_ACCESS_EN, mask_sh), \
 	DMCU_SF(DMCU_RAM_ACCESS_CTRL, \
 			IRAM_WR_ADDR_AUTO_INC, mask_sh), \
+	DMCU_SF(DMCU_RAM_ACCESS_CTRL, \
+			IRAM_RD_ADDR_AUTO_INC, mask_sh), \
 	DMCU_SF(MASTER_COMM_CMD_REG, \
 			MASTER_COMM_CMD_REG_BYTE0, mask_sh), \
 	DMCU_SF(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, mask_sh), \
@@ -89,7 +95,9 @@
 	type DMCU_IRAM_MEM_PWR_STATE; \
 	type IRAM_HOST_ACCESS_EN; \
 	type IRAM_WR_ADDR_AUTO_INC; \
+	type IRAM_RD_ADDR_AUTO_INC; \
 	type DMCU_ENABLE; \
+	type UC_IN_STOP_MODE; \
 	type MASTER_COMM_CMD_REG_BYTE0; \
 	type MASTER_COMM_INTERRUPT; \
 	type DPHY_RX_FAST_TRAINING_CAPABLE; \
@@ -112,6 +120,7 @@ struct dce_dmcu_mask {
 
 struct dce_dmcu_registers {
 	uint32_t DMCU_CTRL;
+	uint32_t DMCU_STATUS;
 	uint32_t DMCU_RAM_ACCESS_CTRL;
 	uint32_t DCI_MEM_PWR_STATUS;
 	uint32_t DMU_MEM_PWR_CNTL;
@@ -127,6 +136,7 @@ struct dce_dmcu_registers {
 	uint32_t DMCU_IRAM_RD_DATA;
 	uint32_t DMCU_INTERRUPT_TO_UC_EN_MASK;
 	uint32_t SMU_INTERRUPT_CONTROL;
+	uint32_t DC_DMCU_SCRATCH;
 };
 
 struct dce_dmcu {
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +5 -0
index d23cd1618623..63bed921b895 100644
@@ -31,6 +31,7 @@
 #include "dce110/dce110_hw_sequencer.h"
 #include "dce/dce_hwseq.h"
 #include "abm.h"
+#include "dmcu.h"
 #include "dcn10/dcn10_timing_generator.h"
 #include "dcn10/dcn10_dpp.h"
 #include "dcn10/dcn10_mpc.h"
@@ -863,6 +864,7 @@ static void dcn10_init_hw(struct dc *dc)
 {
 	int i;
 	struct abm *abm = dc->res_pool->abm;
+	struct dmcu *dmcu = dc->res_pool->dmcu;
 	struct dce_hwseq *hws = dc->hwseq;
 
 	if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
@@ -925,6 +927,9 @@ static void dcn10_init_hw(struct dc *dc)
 		abm->funcs->abm_init(abm);
 	}
 
+	if (dmcu != NULL)
+		dmcu->funcs->dmcu_init(dmcu);
+
 	/* power AFMT HDMI memory TODO: may move to dis/en output save power*/
 	REG_WRITE(DIO_MEM_PWR_CTRL, 0);
 
drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h +16 -0
index 0574c29cc4a8..67996c662c0b 100644
@@ -27,12 +27,28 @@
 
 #include "dm_services_types.h"
 
+enum dmcu_state {
+	DMCU_NOT_INITIALIZED = 0,
+	DMCU_RUNNING = 1
+};
+
+struct dmcu_version {
+	unsigned int day;
+	unsigned int month;
+	unsigned int year;
+	unsigned int interface_version;
+};
+
 struct dmcu {
 	struct dc_context *ctx;
 	const struct dmcu_funcs *funcs;
+
+	enum dmcu_state dmcu_state;
+	struct dmcu_version dmcu_version;
 };
 
 struct dmcu_funcs {
+	bool (*dmcu_init)(struct dmcu *dmcu);
 	bool (*load_iram)(struct dmcu *dmcu,
 			unsigned int start_offset,
 			const char *src,
Signature · 6 lines
2.14.1

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

PATCH 28/28 drm/amd/display: Only add stream to freesync when modeset required

In reply to a message not in the archive

From: "Leo (Sunpeng) Li" <[email protected]>

This is a follow-up patch to:

Leo (Sunpeng) Li Cleanup code that enables freesync

We should only add a stream to freesync if a modeset was requested, so we don't fill the core freesync map with pointless streams.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 28 +++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +21 -7
index 812a0016869f..4202fd108509 100644
@@ -4144,12 +4144,28 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	 * are removed from freesync module
 	 */
 	if (adev->dm.freesync_module) {
-		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 			struct amdgpu_dm_connector *aconnector = NULL;
 			struct dm_connector_state *dm_new_con_state = NULL;
 			struct amdgpu_crtc *acrtc = NULL;
+			bool modeset_needed;
 
 			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+			dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
+			modeset_needed = modeset_required(
+					new_crtc_state,
+					dm_new_crtc_state->stream,
+					dm_old_crtc_state->stream);
+			/* We add stream to freesync if:
+			 * 1. Said stream is not null, and
+			 * 2. A modeset is requested. This means that the
+			 *    stream was removed previously, and needs to be
+			 *    replaced.
+			 */
+			if (dm_new_crtc_state->stream == NULL ||
+					!modeset_needed)
+				continue;
+
 			acrtc = to_amdgpu_crtc(crtc);
 
 			aconnector =
@@ -4169,12 +4185,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 					state, &aconnector->base);
 			dm_new_con_state = to_dm_connector_state(new_con_state);
 
-			if (dm_new_crtc_state->stream) {
-				mod_freesync_set_user_enable(adev->dm.freesync_module,
-							     &dm_new_crtc_state->stream,
-							     1,
-							     &dm_new_con_state->user_enable);
-			}
+			mod_freesync_set_user_enable(adev->dm.freesync_module,
+						     &dm_new_crtc_state->stream,
+						     1,
+						     &dm_new_con_state->user_enable);
 		}
 	}
 
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#34 lore raw
In reply to a message not in the archive

Still looking for Reviewed-by for patches 2, 3, 22-24.

Harry

Quoted 70 lines · Harry Wentland

* Fixed hotplug issue (mainly on HDMI, but affected DP as well)
* Use new DRM state iterators
* Couple of Dave's cleanups rerolled on new DML
* Bunch of Raven work

Anthony Koo (2):
drm/amd/display: Add APU cap in dc_caps
drm/amd/display: DMCU FW loading from PSP

Bhawanpreet Lakha (2):
drm/amd/display: Add null check for 24BPP (xfm and dpp) drm/amd/display: Atomic freesync ASSERT fix

Dave Airlie (3):
amdgpu/dc: drop dml_util_is_420
amdgpu/dc: inline dml_round_to_multiple drm/amd/display: Use DRM new-style object iterators.

Harry Wentland (6):
drm/amd/display: Small comment on dc_commit_planes_to_stream amdgpu/dc: inline a bunch of the dml wrappers. drm/amd/display: Add bunch of missing license headers in DML drm/amd/display: Cleanup some fail labels in dcn10_resource drm/amd/display: Clean some unneeded defines from ddc_service_types.h drm/amd/display: Explicit casting for grph object ids

Jerry Zuo (1):
drm/amd/display: Fix no display on Fiji

Leo (Sunpeng) Li (9):
drm/amd/display: Use new DRM API where possible drm/amd/display: Unify DRM state variable namings. drm/amd/display: Unify amdgpu_dm state variable namings. drm/amd/display: Fix typo
drm/amd/display: Remove useless pcrtc pointer drm/amd/display: Do not release DC state on S3 resume drm/amd/display: Cleanup code that enables freesync drm/amd/display: Should disable when new stream is null drm/amd/display: Only add stream to freesync when modeset required

Mikita Lipski (1):
drm/amd/display: Adding DCN1 registers

Yongqiang Sun (3):
drm/amd/display: Move lock to front end program. drm/amd/display: Check cursor address before program. drm/amd/display: Set cursor position as per address.

Yue Hin Lau (1):
drm/amd/display: cleaning up hubp for dcn

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 441 ++++++++++-----------
 drivers/gpu/drm/amd/display/dc/core/dc.c           |  60 +--
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c  |  18 +-
 drivers/gpu/drm/amd/display/dc/dc.h                |   1 +
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c      | 176 +++++++-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h      |  12 +-
 .../amd/display/dc/dce110/dce110_hw_sequencer.c    |  41 +-
 .../drm/amd/display/dc/dce110/dce110_resource.c    |   1 +
 .../gpu/drm/amd/display/dc/dce80/dce80_resource.c  |   2 +
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c  |  16 +-
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h  | 345 ++++++++--------
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c  |  26 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c  |  62 ++-
 .../amd/display/dc/dcn10/dcn10_timing_generator.h  |  33 +-
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.c  |  27 ++
 .../gpu/drm/amd/display/dc/dml/display_mode_vba.h  |  24 +-
 .../drm/amd/display/dc/dml/display_rq_dlg_calc.c   |   2 +
 .../amd/display/dc/dml/dml1_display_rq_dlg_calc.c  |   2 +
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.c   | 119 +-----
Quoted 9 lines
 .../gpu/drm/amd/display/dc/dml/dml_common_defs.h   |  17 -
 .../gpu/drm/amd/display/dc/dml/dml_inline_defs.h   | 121 ++++++
 .../gpu/drm/amd/display/dc/dml/soc_bounding_box.c  |   1 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h       |  16 +
 .../drm/amd/display/include/ddc_service_types.h    |  33 --
 .../gpu/drm/amd/display/include/grph_object_id.h   |  12 +-
 25 files changed, 894 insertions(+), 714 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h

_______________________________________________
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): 1eda1702-cdd5-ce4d-0093-81f8fe0ebf34-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#36 lore raw

Also just a reminder to submit a follow up to patch 15 to fix memory leak.

Thanks,

Andrey

Quoted 84 lines · Harry Wentland

Still looking for Reviewed-by for patches 2, 3, 22-24.

Harry

Quoted 77 lines · Harry Wentland

* Fixed hotplug issue (mainly on HDMI, but affected DP as well)
* Use new DRM state iterators
* Couple of Dave's cleanups rerolled on new DML
* Bunch of Raven work

Anthony Koo (2):
drm/amd/display: Add APU cap in dc_caps
drm/amd/display: DMCU FW loading from PSP

Bhawanpreet Lakha (2):
drm/amd/display: Add null check for 24BPP (xfm and dpp) drm/amd/display: Atomic freesync ASSERT fix

Dave Airlie (3):
amdgpu/dc: drop dml_util_is_420
amdgpu/dc: inline dml_round_to_multiple drm/amd/display: Use DRM new-style object iterators.

Harry Wentland (6):
drm/amd/display: Small comment on dc_commit_planes_to_stream amdgpu/dc: inline a bunch of the dml wrappers. drm/amd/display: Add bunch of missing license headers in DML drm/amd/display: Cleanup some fail labels in dcn10_resource drm/amd/display: Clean some unneeded defines from ddc_service_types.h drm/amd/display: Explicit casting for grph object ids

Jerry Zuo (1):
drm/amd/display: Fix no display on Fiji

Leo (Sunpeng) Li (9):
drm/amd/display: Use new DRM API where possible drm/amd/display: Unify DRM state variable namings. drm/amd/display: Unify amdgpu_dm state variable namings. drm/amd/display: Fix typo
drm/amd/display: Remove useless pcrtc pointer drm/amd/display: Do not release DC state on S3 resume drm/amd/display: Cleanup code that enables freesync drm/amd/display: Should disable when new stream is null drm/amd/display: Only add stream to freesync when modeset required

Mikita Lipski (1):
drm/amd/display: Adding DCN1 registers

Yongqiang Sun (3):
drm/amd/display: Move lock to front end program. drm/amd/display: Check cursor address before program. drm/amd/display: Set cursor position as per address.

Yue Hin Lau (1):
drm/amd/display: cleaning up hubp for dcn

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 441 ++++++++++-----------
  drivers/gpu/drm/amd/display/dc/core/dc.c           |  60 +--
  drivers/gpu/drm/amd/display/dc/core/dc_resource.c  |  18 +-
  drivers/gpu/drm/amd/display/dc/dc.h                |   1 +
  drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c      | 176 +++++++-
  drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h      |  12 +-
  .../amd/display/dc/dce110/dce110_hw_sequencer.c    |  41 +-
  .../drm/amd/display/dc/dce110/dce110_resource.c    |   1 +
  .../gpu/drm/amd/display/dc/dce80/dce80_resource.c  |   2 +
  drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c  |  16 +-
  drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h  | 345 ++++++++--------
  .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c  |  26 +-
  .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c  |  62 ++-
  .../amd/display/dc/dcn10/dcn10_timing_generator.h  |  33 +-
  .../gpu/drm/amd/display/dc/dml/display_mode_vba.c  |  27 ++
  .../gpu/drm/amd/display/dc/dml/display_mode_vba.h  |  24 +-
  .../drm/amd/display/dc/dml/display_rq_dlg_calc.c   |   2 +
  .../amd/display/dc/dml/dml1_display_rq_dlg_calc.c  |   2 +
  .../gpu/drm/amd/display/dc/dml/dml_common_defs.c   | 119 +-----
  .../gpu/drm/amd/display/dc/dml/dml_common_defs.h   |  17 -
  .../gpu/drm/amd/display/dc/dml/dml_inline_defs.h   | 121 ++++++
  .../gpu/drm/amd/display/dc/dml/soc_bounding_box.c  |   1 +
  drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h       |  16 +
  .../drm/amd/display/include/ddc_service_types.h    |  33 --
  .../gpu/drm/amd/display/include/grph_object_id.h   |  12 +-
  25 files changed, 894 insertions(+), 714 deletions(-)
Quoted 2 lines

create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h

Quoted 4 lines

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

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