Skip to contentSkip to conversation

Display Stream Compression (DSC) for AMD Navi

PATCH Superseded David Francis 5 participants 26 messages Aug 20, 2019 – Aug 21, 2019 11 messages not in the archive

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Display Stream Compression (DSC) for AMD Navi

This patchset enables Display Stream Compression (DSC) on DP connectors on Navi ASICs, both SST and DSC.

8k60 and 4k144 support requires ODM combine, an AMD internal feature that may be a bit buggy right now.

Patches 1 through 5 enable DSC for SST. Most of the work was already done in the Navi promotion patches; this just hooks it up to the atomic interface. The first two reverts are of temporary changes to block off DSC. The third is of a commit that was accidentally promoted twice. The fourth and last revert fixes a potential issue with ODM combine.

Patches 6 and 7 are fixes for bugs that would be exposed by MST DSC. One fix is with the MST code and the other in the DSC code.

Patches 8, 9, and 10 are small DRM changes required for DSC MST:
FEC, a new bit in the standard; some export definitions; and a previously uninitialized variable.

Patches 11 through 14 are the DSC MST policy itself. This includes the code for detecting and validating DSC capabilities, enabling DSC over a link, computing the fair DSC configurations for multiple DSC displays, and adding to atomic state crtcs that might need reprogramming due to DSC.

v2: Updating patches 6 and 14 in respoinse to Nick's feedback

David Francis (14):
Revert "drm/amd/display: skip dsc config for navi10 bring up" Revert "drm/amd/display: navi10 bring up skip dsc encoder config" Revert "drm/amd/display: add global master update lock for DCN2" Revert "drm/amd/display: Fix underscan not using proper scaling" drm/amd/display: Enable SST DSC in DM
drm/dp-mst: Use dc and drm helpers to compute timeslots drm/amd/display: Initialize DSC PPS variables to 0 drm/dp-mst: Parse FEC capability on MST ports drm/dp-mst: Export symbols for dpcd read/write drm/dp-mst: Fill branch->num_ports
drm/amd/display: Validate DSC caps on MST endpoints drm/amd/display: Write DSC enable to MST DPCD drm/amd/display: MST DSC compute fair share drm/amd/display: Trigger modesets on MST DSC connectors

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 110 +++-
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  48 +-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 498 +++++++++++++++++-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |   5 +
 drivers/gpu/drm/amd/display/dc/core/dc.c      |  12 +-
 .../drm/amd/display/dc/core/dc_link_hwss.c    |   3 +
 .../gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c  |   3 +
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c    |   4 -
 .../gpu/drm/amd/display/dc/dcn20/dcn20_optc.c |  72 +--
 .../gpu/drm/amd/display/dc/dcn20/dcn20_optc.h |   3 -
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |   7 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.h |   1 +
 .../display/dc/dcn20/dcn20_stream_encoder.c   |   8 -
 .../amd/display/dc/inc/hw/timing_generator.h  |   2 -
 drivers/gpu/drm/drm_dp_mst_topology.c         |  47 ++
 include/drm/drm_dp_mst_helper.h               |   5 +-
 16 files changed, 708 insertions(+), 120 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v2 1/14 Revert "drm/amd/display: skip dsc config for navi10 bring up"

This reverts commit 55ad81f3510ec1a1c19e6a4d8a6319812d07d256.

optc dsc config was causing warnings due to missing register definitions. With the registers restored, the function can be re-enabled

The reverted commit also disabled sanity checks and dsc power gating. The sanity check warnings are not associated with dsc, and power gating on dsc still has an issue on non-dsc monitors where the dsc hardware block is never init and so cannot respond to power gating requests. Therefore, those are left as is

---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c +0 -9
index aedf9de1c947..99070e93020b 100644
@@ -191,15 +191,6 @@ void optc2_set_dsc_config(struct timing_generator *optc,
 					uint32_t dsc_slice_width)
 {
 	struct optc *optc1 = DCN10TG_FROM_TG(optc);
-	uint32_t data_format = 0;
-	/* skip if dsc mode is not changed */
-	data_format = dm_read_reg(CTX, REG(OPTC_DATA_FORMAT_CONTROL));
-
-	data_format = data_format & 0x30; /* bit5:4 */
-	data_format = data_format >> 4;
-
-	if (data_format == dsc_mode)
-		return;
 
 	REG_UPDATE(OPTC_DATA_FORMAT_CONTROL,
 		OPTC_DSC_MODE, dsc_mode);
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): 20190820191203.25807-1-David.Francis-5C7GfCeVMHo@public.gmane.org

#3 lore raw

PATCH v2 2/14 Revert "drm/amd/display: navi10 bring up skip dsc encoder config"

This reverts commit 5f2fd347eeff7d4ce271920efd47baaa18fe968c.

Re-enable enc2_dp_set_dsc_config. This function caused warnings due to missing register definitions. With the registers added, this now works

---
 .../gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c   | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c +0 -8
index 6d54942ab98b..a4e67286cdad 100644
@@ -277,14 +277,6 @@ static void enc2_dp_set_dsc_config(struct stream_encoder *enc,
 					uint32_t dsc_slice_width)
 {
 	struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc);
-	uint32_t dsc_value = 0;
-
-	dsc_value = REG_READ(DP_DSC_CNTL);
-
-	/* dsc disable skip */
-	if ((dsc_value & 0x3) == 0x0)
-		return;
-
 
 	REG_UPDATE_2(DP_DSC_CNTL,
 			DP_DSC_MODE, dsc_mode,
Signature · 6 lines
2.17.1

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

PATCH v2 5/14 drm/amd/display: Enable SST DSC in DM

In reply to a message not in the archive

In create_stream_for_sink, check for SST DP connectors

Parse DSC caps to DC format, then, if DSC is supported, compute the config

DSC hardware will be programmed by dc_commit_state

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ++++++++++++-------
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  4 ++-
 2 files changed, 24 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +21 -11
index 911fe78b47c1..84249057e181 100644
@@ -3576,6 +3576,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 	bool scale = dm_state ? (dm_state->scaling != RMX_OFF) : false;
 	int mode_refresh;
 	int preferred_refresh = 0;
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+	struct dsc_dec_dpcd_caps dsc_caps;
+	uint32_t link_bandwidth_kbps;
+#endif
 
 	struct dc_sink *sink = NULL;
 	if (aconnector == NULL) {
@@ -3648,17 +3652,23 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 			&mode, &aconnector->base, con_state, old_stream);
 
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
-	/* stream->timing.flags.DSC = 0; */
-        /*  */
-	/* if (aconnector->dc_link && */
-	/* 		aconnector->dc_link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT #<{(|&& */
-	/* 		aconnector->dc_link->dpcd_caps.dsc_caps.dsc_basic_caps.is_dsc_supported|)}>#) */
-	/* 	if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc, */
-	/* 			&aconnector->dc_link->dpcd_caps.dsc_caps, */
-	/* 			dc_link_bandwidth_kbps(aconnector->dc_link, dc_link_get_link_cap(aconnector->dc_link)), */
-	/* 			&stream->timing, */
-	/* 			&stream->timing.dsc_cfg)) */
-	/* 		stream->timing.flags.DSC = 1; */
+	stream->timing.flags.DSC = 0;
+
+	if (aconnector->dc_link && sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT) {
+		dc_dsc_parse_dsc_dpcd(aconnector->dc_link->dpcd_caps.dsc_caps.dsc_basic_caps.raw,
+				      aconnector->dc_link->dpcd_caps.dsc_caps.dsc_ext_caps.raw,
+				      &dsc_caps);
+		link_bandwidth_kbps = dc_link_bandwidth_kbps(aconnector->dc_link,
+							     dc_link_get_link_cap(aconnector->dc_link));
+
+		if (dsc_caps.is_dsc_supported)
+			if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc,
+						  &dsc_caps,
+						  link_bandwidth_kbps,
+						  &stream->timing,
+						  &stream->timing.dsc_cfg))
+				stream->timing.flags.DSC = 1;
+	}
 #endif
 
 	update_stream_scaling_settings(&mode, dm_state, stream);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +3 -1
index 7cf0573ab25f..5f2c315b18ba 100644
@@ -549,7 +549,9 @@ bool dm_helpers_dp_write_dsc_enable(
 		bool enable
 )
 {
-	return false;
+	uint8_t enable_dsc = enable ? 1 : 0;
+
+	return dm_helpers_dp_write_dpcd(ctx, stream->sink->link, DP_DSC_ENABLE, &enable_dsc, 1);
 }
 #endif
 
Signature · 6 lines
2.17.1

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

PATCH v2 6/14 drm/dp-mst: Use dc and drm helpers to compute timeslots

In reply to a message not in the archive

We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots

These helpers
-Did not take DSC timings into account
-Used the link rate and lane count of the link's aux device,
which are not the same as the link's current cap
-Did not take FEC into account (FEC reduces the PBN per timeslot)

For converting timing into PBN, add a new function drm_dp_calc_pbn_mode_dsc that handles the DSC case

For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code.

v2: Add drm helper for clock to pbn conversion

Cc Jerry Zuo <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++---
 drivers/gpu/drm/drm_dp_mst_topology.c         | 41 +++++++++++++++++++
 include/drm/drm_dp_mst_helper.h               |  2 +-
 3 files changed, 54 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +12 -6
index 5f2c315b18ba..dfa99e0d6e64 100644
@@ -189,8 +189,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 	int slots = 0;
 	bool ret;
 	int clock;
-	int bpp = 0;
 	int pbn = 0;
+	int pbn_per_timeslot, bpp = 0;
 
 	aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
 
@@ -208,7 +208,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 		clock = stream->timing.pix_clk_100hz / 10;
 
 		switch (stream->timing.display_color_depth) {
-
 		case COLOR_DEPTH_666:
 			bpp = 6;
 			break;
@@ -234,11 +233,18 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 
 		bpp = bpp * 3;
 
-		/* TODO need to know link rate */
-
-		pbn = drm_dp_calc_pbn_mode(clock, bpp);
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+		if (stream->timing.flags.DSC)
+			pbn = drm_dp_calc_pbn_mode_dsc(clock,
+					stream->timing.dsc_cfg.bits_per_pixel);
+		else
+#endif
+			pbn = drm_dp_calc_pbn_mode(clock, bpp);
 
-		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
+		/* Convert kilobits per second / 64 (for 64 timeslots) to pbn (54/64 megabytes per second) */
+		pbn_per_timeslot = dc_link_bandwidth_kbps(
+				stream->link, dc_link_get_link_cap(stream->link)) / (8 * 1000 * 54);
+		slots = DIV_ROUND_UP(pbn, pbn_per_timeslot);
 		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
 
 		if (!ret)
drivers/gpu/drm/drm_dp_mst_topology.c +41 -0

47 lines not on this page · raw message

include/drm/drm_dp_mst_helper.h +1 -1
index 2ba6253ea6d3..ddb518f2157a 100644
@@ -611,7 +611,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_
 
 
 int drm_dp_calc_pbn_mode(int clock, int bpp);
-
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp);
 
 bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
 			      struct drm_dp_mst_port *port, int pbn, int slots);
Signature · 6 lines
2.17.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): 20190820191203.25807-7-David.Francis-5C7GfCeVMHo@public.gmane.org

#7 lore raw

Re: [PATCH v2 06/14] drm/dp-mst: Use dc and drm helpers to compute timeslots

Some nitpicks below

Quoted 88 lines · David Francis

We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots

These helpers

(quoted diff) +0 -3
-Did not take DSC timings into account
-Used the link rate and lane count of the link's aux device,
 which are not the same as the link's current cap
-Did not take FEC into account (FEC reduces the PBN per timeslot)

For converting timing into PBN, add a new function drm_dp_calc_pbn_mode_dsc that handles the DSC case

For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code.

v2: Add drm helper for clock to pbn conversion

Cc Jerry Zuo <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++---
 drivers/gpu/drm/drm_dp_mst_topology.c         | 41 +++++++++++++++++++
 include/drm/drm_dp_mst_helper.h               |  2 +-
 3 files changed, 54 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +9 -6
index 5f2c315b18ba..dfa99e0d6e64 100644
@@ -189,8 +189,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 	int slots = 0;
 	bool ret;
 	int clock;
-	int bpp = 0;
 	int pbn = 0;
+	int pbn_per_timeslot, bpp = 0;
 
 	aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
 
@@ -208,7 +208,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 		clock = stream->timing.pix_clk_100hz / 10;
 
 		switch (stream->timing.display_color_depth) {
-
 		case COLOR_DEPTH_666:
 			bpp = 6;
 			break;
@@ -234,11 +233,18 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 
 		bpp = bpp * 3;
 
-		/* TODO need to know link rate */
-
-		pbn = drm_dp_calc_pbn_mode(clock, bpp);
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+		if (stream->timing.flags.DSC)
+			pbn = drm_dp_calc_pbn_mode_dsc(clock,
+					stream-
 >timing.dsc_cfg.bits_per_pixel);
+		else
+#endif
+			pbn = drm_dp_calc_pbn_mode(clock, bpp);
 
-		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
+		/* Convert kilobits per second / 64 (for 64 timeslots) to pbn

(54/64 megabytes per second) */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +2 -0
+		pbn_per_timeslot = dc_link_bandwidth_kbps(
+				stream->link, dc_link_get_link_cap(stream-
Quoted 1 line

link)) / (8 * 1000 * 54);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -0
+		slots = DIV_ROUND_UP(pbn, pbn_per_timeslot);
 		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
 
 		if (!ret)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index 398e7314ea8b..d789b7af7dbf 100644
@@ -3588,6 +3588,47 @@ static int test_calc_pbn_mode(void)
 	return 0;
 }
 
+/**
+ * drm_dp_calc_pbn_mode_dsc() - Calculate the PBN for a mode with DSC
Quoted 6 lines

enabled.
+ * @clock: dot clock for the mode
+ * @dsc_bpp: dsc bits per pixel x16 (e.g. dsc_bpp = 136 is 8.5 bpp)
+ *
+ * This uses the formula in the spec to calculate the PBN value for a mode,
+ * given that the mode is using DSC

You should use the proper kdoc formatting for documenting return values (not all of the DP MST code does this currently, but that's a bug I haven't taken the time to fix :):

/*
* foo_bar() - foo the bar
*
* foos the bar, guaranteed
* Returns:
* Some magic number
*/

Quoted 53 lines

+ */

drivers/gpu/drm/drm_dp_mst_topology.c +33 -0
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp)
+{
+	u64 kbps;
+	s64 peak_kbps;
+	u32 numerator;
+	u32 denominator;
+
+	kbps = clock * dsc_bpp;
+
+	/*
+	 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
+	 * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
+	 * common multiplier to render an integer PBN for all link rate/lane
+	 * counts combinations
+	 * calculate
+	 * peak_kbps *= (1/16) bppx16 to bpp
+	 * peak_kbps *= (1006/1000)
+	 * peak_kbps *= (64/54)
+	 * peak_kbps *= 8    convert to bytes
+	 *
+	 * Divide numerator and denominator by 16 to avoid overflow
+	 */
+
+	numerator = 64 * 1006 / 16;
+	denominator = 54 * 8 * 1000 * 1000;
+
+	kbps *= numerator;
+	peak_kbps = drm_fixp_from_fraction(kbps, denominator);
+
+	return drm_fixp2int_ceil(peak_kbps);
+}
+EXPORT_SYMBOL(drm_dp_calc_pbn_mode_dsc);
+
 /* we want to kick the TX after we've ack the up/down IRQs. */
 static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr)
 {
include/drm/drm_dp_mst_helper.h +1 -1
index 2ba6253ea6d3..ddb518f2157a 100644
@@ -611,7 +611,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector
 *connector, struct drm_dp_
 
 
 int drm_dp_calc_pbn_mode(int clock, int bpp);
-
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp);
 
 bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,

struct drm_dp_mst_port *port, int pbn, int
slots);

Signature · 7 lines
Cheers,
	Lyude Paul

_______________________________________________
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): eccdbdb90afa28079a92b9cd959a1cb54ed952b3.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#9 lore raw

Re: [PATCH v2 06/14] drm/dp-mst: Use dc and drm helpers to compute timeslots

Quoted 20 lines · Lyude Paul

Some nitpicks below

Quoted 17 lines · David Francis

We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots

These helpers

(quoted diff) +0 -3
-Did not take DSC timings into account
-Used the link rate and lane count of the link's aux device,
  which are not the same as the link's current cap
-Did not take FEC into account (FEC reduces the PBN per timeslot)

For converting timing into PBN, add a new function drm_dp_calc_pbn_mode_dsc that handles the DSC case

For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code.

Quoted 5 lines
Quoted 5 lines

v2: Add drm helper for clock to pbn conversion

Cc Jerry Zuo <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

I would like ot see Lyude's nitpicks addressed but also having this patch split into one that just adds the helper and another that uses it in amdgpu.

Nicholas Kazlauskas

Quoted 131 lines
Quoted 66 lines
---
  .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++---
  drivers/gpu/drm/drm_dp_mst_topology.c         | 41 +++++++++++++++++++
  include/drm/drm_dp_mst_helper.h               |  2 +-
  3 files changed, 54 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +9 -6
index 5f2c315b18ba..dfa99e0d6e64 100644
@@ -189,8 +189,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
  	int slots = 0;
  	bool ret;
  	int clock;
-	int bpp = 0;
  	int pbn = 0;
+	int pbn_per_timeslot, bpp = 0;
 
  	aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
 
@@ -208,7 +208,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
  		clock = stream->timing.pix_clk_100hz / 10;
 
  		switch (stream->timing.display_color_depth) {
-
  		case COLOR_DEPTH_666:
  			bpp = 6;
  			break;
@@ -234,11 +233,18 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 
  		bpp = bpp * 3;
 
-		/* TODO need to know link rate */
-
-		pbn = drm_dp_calc_pbn_mode(clock, bpp);
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+		if (stream->timing.flags.DSC)
+			pbn = drm_dp_calc_pbn_mode_dsc(clock,
+					stream-
 > timing.dsc_cfg.bits_per_pixel);
+		else
+#endif
+			pbn = drm_dp_calc_pbn_mode(clock, bpp);
 
-		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
+		/* Convert kilobits per second / 64 (for 64 timeslots) to pbn

(54/64 megabytes per second) */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +2 -0
+		pbn_per_timeslot = dc_link_bandwidth_kbps(
+				stream->link, dc_link_get_link_cap(stream-
Quoted 1 line

link)) / (8 * 1000 * 54);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -0
+		slots = DIV_ROUND_UP(pbn, pbn_per_timeslot);
  		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
 
  		if (!ret)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index 398e7314ea8b..d789b7af7dbf 100644
@@ -3588,6 +3588,47 @@ static int test_calc_pbn_mode(void)
  	return 0;
  }
 
+/**
+ * drm_dp_calc_pbn_mode_dsc() - Calculate the PBN for a mode with DSC
Quoted 6 lines

enabled.
+ * @clock: dot clock for the mode
+ * @dsc_bpp: dsc bits per pixel x16 (e.g. dsc_bpp = 136 is 8.5 bpp)
+ *
+ * This uses the formula in the spec to calculate the PBN value for a mode,
+ * given that the mode is using DSC

You should use the proper kdoc formatting for documenting return values (not all of the DP MST code does this currently, but that's a bug I haven't taken the time to fix :):

/*
* foo_bar() - foo the bar
*
* foos the bar, guaranteed
* Returns:
* Some magic number
*/

Quoted 46 lines

+ */

drivers/gpu/drm/drm_dp_mst_topology.c +33 -0
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp)
+{
+	u64 kbps;
+	s64 peak_kbps;
+	u32 numerator;
+	u32 denominator;
+
+	kbps = clock * dsc_bpp;
+
+	/*
+	 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
+	 * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
+	 * common multiplier to render an integer PBN for all link rate/lane
+	 * counts combinations
+	 * calculate
+	 * peak_kbps *= (1/16) bppx16 to bpp
+	 * peak_kbps *= (1006/1000)
+	 * peak_kbps *= (64/54)
+	 * peak_kbps *= 8    convert to bytes
+	 *
+	 * Divide numerator and denominator by 16 to avoid overflow
+	 */
+
+	numerator = 64 * 1006 / 16;
+	denominator = 54 * 8 * 1000 * 1000;
+
+	kbps *= numerator;
+	peak_kbps = drm_fixp_from_fraction(kbps, denominator);
+
+	return drm_fixp2int_ceil(peak_kbps);
+}
+EXPORT_SYMBOL(drm_dp_calc_pbn_mode_dsc);
+
  /* we want to kick the TX after we've ack the up/down IRQs. */
  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr)
  {
include/drm/drm_dp_mst_helper.h +0 -0
index 2ba6253ea6d3..ddb518f2157a 100644
@@ -611,7 +611,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector
 *connector, struct drm_dp_
 
 
Quoted 7 lines
Quoted 7 lines
include/drm/drm_dp_mst_helper.h +1 -1
  int drm_dp_calc_pbn_mode(int clock, int bpp);
-
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp);
 
  bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,

struct drm_dp_mst_port *port, int pbn, int
slots);

_______________________________________________
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): f63c563e-3aa5-0772-559b-6b34ef612495-5C7GfCeVMHo@public.gmane.org

#11 lore raw

Re: [PATCH v2 06/14] drm/dp-mst: Use dc and drm helpers to compute timeslots

Quoted 23 lines · Nicholas
Quoted 22 lines · Lyude Paul

Some nitpicks below

Quoted 19 lines · David Francis

We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots

These helpers

(quoted diff) +0 -3
-Did not take DSC timings into account
-Used the link rate and lane count of the link's aux device,
  which are not the same as the link's current cap
-Did not take FEC into account (FEC reduces the PBN per timeslot)

For converting timing into PBN, add a new function drm_dp_calc_pbn_mode_dsc that handles the DSC case

For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code.

v2: Add drm helper for clock to pbn conversion

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Cc Jerry Zuo <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

I would like ot see Lyude's nitpicks addressed but also having this patch split into one that just adds the helper and another that uses it in amdgpu.

Sgtm!

Quoted 151 lines

Nicholas Kazlauskas

Quoted 148 lines
Quoted 71 lines
---
  .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++---
  drivers/gpu/drm/drm_dp_mst_topology.c         | 41 +++++++++++++++++++
  include/drm/drm_dp_mst_helper.h               |  2 +-
  3 files changed, 54 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
index 5f2c315b18ba..dfa99e0d6e64 100644
@@ -189,8 +189,8 @@ bool

dm_helpers_dp_mst_write_payload_allocation_table(
int slots = 0;
bool ret;
int clock;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -1
-	int bpp = 0;
  	int pbn = 0;
+	int pbn_per_timeslot, bpp = 0;
 
  	aconnector = (struct amdgpu_dm_connector *)stream-
Quoted 1 line

dm_stream_context;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
@@ -208,7 +208,6 @@ bool

dm_helpers_dp_mst_write_payload_allocation_table(
clock = stream->timing.pix_clk_100hz / 10;

  		switch (stream->timing.display_color_depth) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -1
-
  		case COLOR_DEPTH_666:
  			bpp = 6;
  			break;
@@ -234,11 +233,18 @@ bool

dm_helpers_dp_mst_write_payload_allocation_table(

  		bpp = bpp * 3;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +4 -3
-		/* TODO need to know link rate */
-
-		pbn = drm_dp_calc_pbn_mode(clock, bpp);
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+		if (stream->timing.flags.DSC)
+			pbn = drm_dp_calc_pbn_mode_dsc(clock,
+					stream-
Quoted 1 line

timing.dsc_cfg.bits_per_pixel);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +4 -1
+		else
+#endif
+			pbn = drm_dp_calc_pbn_mode(clock, bpp);
 
-		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
+		/* Convert kilobits per second / 64 (for 64 timeslots) to pbn

(54/64 megabytes per second) */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +2 -0
+		pbn_per_timeslot = dc_link_bandwidth_kbps(
+				stream->link, dc_link_get_link_cap(stream-
Quoted 1 line

link)) / (8 * 1000 * 54);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -0
+		slots = DIV_ROUND_UP(pbn, pbn_per_timeslot);
  		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn,

slots);

if (!ret)

drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index 398e7314ea8b..d789b7af7dbf 100644
@@ -3588,6 +3588,47 @@ static int test_calc_pbn_mode(void)
  	return 0;
  }
 
+/**
+ * drm_dp_calc_pbn_mode_dsc() - Calculate the PBN for a mode with DSC
Quoted 7 lines

enabled.
+ * @clock: dot clock for the mode
+ * @dsc_bpp: dsc bits per pixel x16 (e.g. dsc_bpp = 136 is 8.5 bpp)
+ *
+ * This uses the formula in the spec to calculate the PBN value for a mode,
+ * given that the mode is using DSC

You should use the proper kdoc formatting for documenting return values (not
all of the DP MST code does this currently, but that's a bug I haven't taken
the time to fix :):

/*
* foo_bar() - foo the bar
*
* foos the bar, guaranteed
* Returns:
* Some magic number
*/

Quoted 55 lines

+ */

drivers/gpu/drm/drm_dp_mst_topology.c +33 -0
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp)
+{
+	u64 kbps;
+	s64 peak_kbps;
+	u32 numerator;
+	u32 denominator;
+
+	kbps = clock * dsc_bpp;
+
+	/*
+	 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
+	 * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
+	 * common multiplier to render an integer PBN for all link rate/lane
+	 * counts combinations
+	 * calculate
+	 * peak_kbps *= (1/16) bppx16 to bpp
+	 * peak_kbps *= (1006/1000)
+	 * peak_kbps *= (64/54)
+	 * peak_kbps *= 8    convert to bytes
+	 *
+	 * Divide numerator and denominator by 16 to avoid overflow
+	 */
+
+	numerator = 64 * 1006 / 16;
+	denominator = 54 * 8 * 1000 * 1000;
+
+	kbps *= numerator;
+	peak_kbps = drm_fixp_from_fraction(kbps, denominator);
+
+	return drm_fixp2int_ceil(peak_kbps);
+}
+EXPORT_SYMBOL(drm_dp_calc_pbn_mode_dsc);
+
  /* we want to kick the TX after we've ack the up/down IRQs. */
  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr)
  {
include/drm/drm_dp_mst_helper.h +0 -0
index 2ba6253ea6d3..ddb518f2157a 100644
@@ -611,7 +611,7 @@ struct edid *drm_dp_mst_get_edid(struct

drm_connector
*connector, struct drm_dp_

  int drm_dp_calc_pbn_mode(int clock, int bpp);
include/drm/drm_dp_mst_helper.h +1 -1
-
+int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp);
 
  bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
  			      struct drm_dp_mst_port *port, int pbn,

int
slots);

Signature · 7 lines
Cheers,
	Lyude Paul

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

PATCH v2 7/14 drm/amd/display: Initialize DSC PPS variables to 0

In reply to a message not in the archive

For DSC MST, sometimes monitors would break out in full-screen static. The issue traced back to the PPS generation code, where these variables were being used uninitialized and were picking up garbage.

memset to 0 to avoid this

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | 3 +++
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c   | 3 +++
 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +3 -0
index 35c5467e60e8..619ac48edd05 100644
@@ -491,6 +491,9 @@ bool dp_set_dsc_pps_sdp(struct pipe_ctx *pipe_ctx, bool enable)
 		struct dsc_config dsc_cfg;
 		uint8_t dsc_packed_pps[128];
 
+		memset(&dsc_cfg, 0, sizeof(dsc_cfg));
+		memset(dsc_packed_pps, 0, 128);
+
 		/* Enable DSC hw block */
 		dsc_cfg.pic_width = stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right;
 		dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom;
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c +3 -0
index 379c9e4ac63b..16debe6d89f2 100644
@@ -207,6 +207,9 @@ static bool dsc2_get_packed_pps(struct display_stream_compressor *dsc, const str
 	struct dsc_reg_values dsc_reg_vals;
 	struct dsc_optc_config dsc_optc_cfg;
 
+	memset(&dsc_reg_vals, 0, sizeof(dsc_reg_vals));
+	memset(&dsc_optc_cfg, 0, sizeof(dsc_optc_cfg));
+
 	DC_LOG_DSC("Getting packed DSC PPS for DSC Config:");
 	dsc_config_log(dsc, dsc_cfg);
 	DC_LOG_DSC("DSC Picture Parameter Set (PPS):");
Signature · 6 lines
2.17.1

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

PATCH v2 8/14 drm/dp-mst: Parse FEC capability on MST ports

In reply to a message not in the archive

As of DP1.4, ENUM_PATH_RESOURCES returns a bit indicating if FEC can be supported up to that point in the MST network.

The bit is the first byte of the ENUM_PATH_RESOURCES ack reply, bottom-most bit (refer to section 2.11.9.4 of DP standard, v1.4)

That value is needed for FEC and DSC support

Store it on drm_dp_mst_port

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 include/drm/drm_dp_mst_helper.h       | 3 +++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index d789b7af7dbf..b40d975aec76 100644
@@ -552,6 +552,7 @@ static bool drm_dp_sideband_parse_enum_path_resources_ack(struct drm_dp_sideband
 {
 	int idx = 1;
 	repmsg->u.path_resources.port_number = (raw->msg[idx] >> 4) & 0xf;
+	repmsg->u.path_resources.fec_capable = raw->msg[idx] & 0x1;
 	idx++;
 	if (idx > raw->curlen)
 		goto fail_len;
@@ -2180,6 +2181,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
 			DRM_DEBUG_KMS("enum path resources %d: %d %d\n", txmsg->reply.u.path_resources.port_number, txmsg->reply.u.path_resources.full_payload_bw_number,
 			       txmsg->reply.u.path_resources.avail_payload_bw_number);
 			port->available_pbn = txmsg->reply.u.path_resources.avail_payload_bw_number;
+			port->fec_capable = txmsg->reply.u.path_resources.fec_capable;
 		}
 	}
 
include/drm/drm_dp_mst_helper.h +3 -0
index ddb518f2157a..fa973773a4a7 100644
@@ -108,6 +108,8 @@ struct drm_dp_mst_port {
 	 * audio-capable.
 	 */
 	bool has_audio;
+
+	bool fec_capable;
 };
 
 /**
@@ -312,6 +314,7 @@ struct drm_dp_port_number_req {
 
 struct drm_dp_enum_path_resources_ack_reply {
 	u8 port_number;
+	bool fec_capable;
 	u16 full_payload_bw_number;
 	u16 avail_payload_bw_number;
 };
Signature · 6 lines
2.17.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): 20190820191203.25807-9-David.Francis-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#15 lore raw

Re: [PATCH v2 08/14] drm/dp-mst: Parse FEC capability on MST ports

Quoted 67 lines · David Francis

As of DP1.4, ENUM_PATH_RESOURCES returns a bit indicating if FEC can be supported up to that point in the MST network.

The bit is the first byte of the ENUM_PATH_RESOURCES ack reply, bottom-most bit (refer to section 2.11.9.4 of DP standard, v1.4)

That value is needed for FEC and DSC support

Store it on drm_dp_mst_port

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 include/drm/drm_dp_mst_helper.h       | 3 +++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
index d789b7af7dbf..b40d975aec76 100644
@@ -552,6 +552,7 @@ static bool

drm_dp_sideband_parse_enum_path_resources_ack(struct drm_dp_sideband
{

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
 	int idx = 1;
 	repmsg->u.path_resources.port_number = (raw->msg[idx] >> 4) & 0xf;
+	repmsg->u.path_resources.fec_capable = raw->msg[idx] & 0x1;
 	idx++;
 	if (idx > raw->curlen)
 		goto fail_len;
@@ -2180,6 +2181,7 @@ static int drm_dp_send_enum_path_resources(struct
 drm_dp_mst_topology_mgr *mgr,
 			DRM_DEBUG_KMS("enum path resources %d: %d %d\n",

txmsg->reply.u.path_resources.port_number, txmsg-

Quoted 1 line

reply.u.path_resources.full_payload_bw_number,

txmsg-

Quoted 1 line

reply.u.path_resources.avail_payload_bw_number);

port->available_pbn = txmsg-

Quoted 1 line

reply.u.path_resources.avail_payload_bw_number;

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+			port->fec_capable = txmsg-
Quoted 1 line

reply.u.path_resources.fec_capable;

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		}
 	}
include/drm/drm_dp_mst_helper.h +3 -0
index ddb518f2157a..fa973773a4a7 100644
@@ -108,6 +108,8 @@ struct drm_dp_mst_port {
 	 * audio-capable.
 	 */
 	bool has_audio;
+
+	bool fec_capable;
 };
 
 /**
@@ -312,6 +314,7 @@ struct drm_dp_port_number_req {
 
 struct drm_dp_enum_path_resources_ack_reply {
 	u8 port_number;
+	bool fec_capable;
 	u16 full_payload_bw_number;
 	u16 avail_payload_bw_number;
 };
Signature · 7 lines
Cheers,
	Lyude Paul

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

PATCH v2 10/14 drm/dp-mst: Fill branch->num_ports

In reply to a message not in the archive

This field on drm_dp_mst_branch was never filled

Initialize it to zero when the list of ports is created. When a port is added to the list, increment num_ports

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index 5d5bd42da17c..0c580d5279c1 100644
@@ -918,6 +918,7 @@ static struct drm_dp_mst_branch *drm_dp_add_mst_branch_device(u8 lct, u8 *rad)
 	INIT_LIST_HEAD(&mstb->ports);
 	kref_init(&mstb->topology_kref);
 	kref_init(&mstb->malloc_kref);
+	mstb->num_ports = 0;
 	return mstb;
 }
 
@@ -1672,6 +1673,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
 		mutex_lock(&mstb->mgr->lock);
 		drm_dp_mst_topology_get_port(port);
 		list_add(&port->next, &mstb->ports);
+		mstb->num_ports++;
 		mutex_unlock(&mstb->mgr->lock);
 	}
 
Signature · 6 lines
2.17.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): 20190820191203.25807-11-David.Francis-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#18 lore raw

Re: [PATCH v2 10/14] drm/dp-mst: Fill branch->num_ports

Quoted 25 lines · David Francis

This field on drm_dp_mst_branch was never filled

Initialize it to zero when the list of ports is created. When a port is added to the list, increment num_ports

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
index 5d5bd42da17c..0c580d5279c1 100644
@@ -918,6 +918,7 @@ static struct drm_dp_mst_branch
 *drm_dp_add_mst_branch_device(u8 lct, u8 *rad)
 	INIT_LIST_HEAD(&mstb->ports);
 	kref_init(&mstb->topology_kref);
 	kref_init(&mstb->malloc_kref);
+	mstb->num_ports = 0;
 	return mstb;
 }

drivers/gpu/drm/drm_dp_mst_topology.c static void drm_dp_add_port(struct drm_dp_mst_branch · line 1677

Quoted 5 lines
drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
@@ -1672,6 +1673,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch
 *mstb,
 		mutex_lock(&mstb->mgr->lock);
 		drm_dp_mst_topology_get_port(port);
 		list_add(&port->next, &mstb->ports);
+		mstb->num_ports++;

You're forgot to add mstb->num_ports--; lower down in the function:

		if (!port->connector) {
			/* remove it from the port list */
			mutex_lock(&mstb->mgr->lock);
			list_del(&port->next);
/* Right here --------> */
			mutex_unlock(&mstb->mgr->lock);
			/* drop port list reference */
			drm_dp_mst_topology_put_port(port);
			goto out;
		}

With that fixed:

Quoted 3 lines
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		mutex_unlock(&mstb->mgr->lock);
 	}
Signature · 7 lines
Cheers,
	Lyude Paul

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

PATCH v2 11/14 drm/amd/display: Validate DSC caps on MST endpoints

In reply to a message not in the archive

The first step in MST DSC is checking MST endpoints to see how DSC can be enabled

Case 1: DP-to-DP peer device
if the branch immediately upstream has
- PDT = DP_PEER_DEVICE_DP_MST_BRANCHING (2)
- DPCD rev. >= DP 1.4
- Exactly one input and one output
- The output has PDT = DP_PEER_DEVICE_SST_SINK (3)

In this case, DSC could be possible either on the endpoint or the peer device. Prefer the endpoint, which is possible if
- The endpoint has DP_DSC_DECOMPRESSION_IS_SUPPORTED bit set
- The endpoint has DP_FEC_CAPABLE bit set
- The peer device has DSC_PASSTHROUGH_CAPABILITY bit set (from DP v2.0)

Otherwise, use the peer device

Case 2: DP-to-HDMI peer device
If the output port has
- PDT = DP_PEER_DEVICE_DP_LEGACY_CONV (4)
- DPCD rev. >= DP 1.4
- LDPS = true
- MCS = false

In this case, DSC can only be attempted on the peer device (the output port)

Case 3: Virtual DP Sink (Internal Display Panel)
If the output port has
- DPCD rev. >= DP 1.4
- port_num >= 8

In this case, DSC can only be attempted on the peer device (the output port)

Case 4: Synaptix Workaround
If the output has
- link DPCD rev. >= DP 1.4
- link branch_dev_id = 0x90CC24 (Synaptix)
- There is exactly one branch device between the link and output

In this case, DSC can be attempted, but only using the *link* aux device's caps. This is a quirk.

Test for these cases as modes are enumerated for an MST endpoint. We cannot do this during link attach because the dc_sink object will not have been created yet

If no DSC is attempted, zero the DSC caps

Cc Wenjing Liu <[email protected]>
Cc Nikola Cornij <[email protected]>
---
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 123 +++++++++++++++++-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |   3 +
 2 files changed, 125 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +122 -1
index 16218a202b59..58571844f6d5 100644
@@ -25,6 +25,7 @@
 
 #include <linux/version.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_mst_helper.h>
 #include "dm_services.h"
 #include "amdgpu.h"
 #include "amdgpu_dm.h"
@@ -189,6 +190,120 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = {
 	.early_unregister = amdgpu_dm_mst_connector_early_unregister,
 };
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port)
+{
+	struct drm_dp_mst_port *downstream_port;
+
+	if (!port)
+		return false;
+
+	if (port->port_num >= 8 &&
+		port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* Virtual DP Sink (Internal Display Panel) */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
+			!port->mcs &&
+			port->ldps &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-HDMI Protocol Converter */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
+			port->mstb &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-DP */
+		if (port->mstb->num_ports == 2) {
+			list_for_each_entry(downstream_port, &port->mstb->ports, next) {
+				if (!downstream_port->input &&
+						downstream_port->pdt == DP_PEER_DEVICE_SST_SINK)
+					return true;
+			}
+		}
+	}
+	return false;
+}
+
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector)
+{
+	struct drm_dp_mst_port *port = aconnector->port;
+	struct dc_link *link = aconnector->dc_sink->link;
+	u8 down_stream_port_data;
+
+	if (port->mgr->mst_primary == port->parent &&
+			link->dpcd_caps.branch_dev_id == 0x90CC24 &&
+			link->dpcd_caps.dpcd_rev.raw >= DP_DPCD_REV_14) {
+		drm_dp_mst_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT, &down_stream_port_data, 1);
+		if ((down_stream_port_data & 7) != 3)
+			return true;
+	}
+	return false;
+}
+
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static bool validate_dsc_caps_on_connector(struct amdgpu_dm_connector *aconnector)
+{
+	u8 upstream_dsc_caps[16] = { 0 };
+	u8 endpoint_dsc_caps[16] = { 0 };
+	u8 endpoint_fec_caps = 0;
+	struct dc_sink *dc_sink = aconnector->dc_sink;
+	struct drm_dp_mst_port *output_port = aconnector->port;
+	struct drm_dp_mst_port *immediate_upstream_port;
+	struct drm_dp_mst_port *fec_port;
+
+	if (aconnector->port && aconnector->port->parent)
+		immediate_upstream_port = aconnector->port->parent->port_parent;
+	else
+		immediate_upstream_port = NULL;
+
+	fec_port = immediate_upstream_port;
+	while (fec_port) {
+		if (!fec_port->fec_capable)
+			return false;
+
+		fec_port = fec_port->parent->port_parent;
+	}
+
+	if (immediate_upstream_port)
+		drm_dp_mst_dpcd_read(&immediate_upstream_port->aux, DP_DSC_SUPPORT, upstream_dsc_caps, 16);
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_DSC_SUPPORT, endpoint_dsc_caps, 16);
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_FEC_CAPABILITY, &endpoint_fec_caps, 1);
+
+	if (is_virtual_dpcd(immediate_upstream_port)
+			&& (upstream_dsc_caps[0] & 0x2) /* DSC passthrough capability */
+			&& (endpoint_fec_caps & DP_FEC_CAPABLE)
+			&& (endpoint_dsc_caps[0] & DP_DSC_DECOMPRESSION_IS_SUPPORTED)) {
+		/* Enpoint decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = false;
+	} else if (is_virtual_dpcd(immediate_upstream_port)) {
+		/* Virtual DPCD decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (is_virtual_dpcd(output_port)) {
+		/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (synaptix_workaround(aconnector)) {
+		/* Synaptix workaround */
+		aconnector = dc_sink->link->priv;
+		drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, DP_DSC_SUPPORT, upstream_dsc_caps, 16);
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else {
+		return false;
+	}
+
+	return true;
+}
+#endif
+
 static int dm_dp_mst_get_modes(struct drm_connector *connector)
 {
 	struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
@@ -231,10 +346,16 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 		/* dc_link_add_remote_sink returns a new reference */
 		aconnector->dc_sink = dc_sink;
 
-		if (aconnector->dc_sink)
+		if (aconnector->dc_sink) {
 			amdgpu_dm_update_freesync_caps(
 					connector, aconnector->edid);
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+			if (!validate_dsc_caps_on_connector(aconnector))
+				memset(&aconnector->dc_sink->sink_dsc_caps,
+				       0, sizeof(aconnector->dc_sink->sink_dsc_caps));
+#endif
+		}
 	}
 
 	drm_connector_update_edid_property(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +3 -0
index 2da851b40042..8de3d8c30f8d 100644
@@ -32,4 +32,7 @@ struct amdgpu_dm_connector;
 void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
 				       struct amdgpu_dm_connector *aconnector);
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port);
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector);
+
 #endif
Signature · 6 lines
2.17.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): 20190820191203.25807-12-David.Francis-5C7GfCeVMHo@public.gmane.org

#21 lore raw

Re: [PATCH v2 11/14] drm/amd/display: Validate DSC caps on MST endpoints

Hi, I was looking through patchwork and just noticed this series. I've been working on trying to rework a lot of the drm MST helpers (currently on hold for a short bit while I fix some other unrelated issues at work...), and one of the things we're currently missing with our helpers are helpers for handling checking the PBN of downstream sinks (which could be added to drm_dp_mst_atomic_check()). As well, it looks like you could also add a DRM helper for checking for DSC/FEC support on mstbs. Thoughts?

Quoted 245 lines · David Francis

The first step in MST DSC is checking MST endpoints to see how DSC can be enabled

Case 1: DP-to-DP peer device
if the branch immediately upstream has
- PDT = DP_PEER_DEVICE_DP_MST_BRANCHING (2)
- DPCD rev. >= DP 1.4
- Exactly one input and one output
- The output has PDT = DP_PEER_DEVICE_SST_SINK (3)

In this case, DSC could be possible either on the endpoint or the peer device. Prefer the endpoint, which is possible if
- The endpoint has DP_DSC_DECOMPRESSION_IS_SUPPORTED bit set
- The endpoint has DP_FEC_CAPABLE bit set
- The peer device has DSC_PASSTHROUGH_CAPABILITY bit set (from DP v2.0)

Otherwise, use the peer device

Case 2: DP-to-HDMI peer device
If the output port has
- PDT = DP_PEER_DEVICE_DP_LEGACY_CONV (4)
- DPCD rev. >= DP 1.4
- LDPS = true
- MCS = false

In this case, DSC can only be attempted on the peer device (the output port)

Case 3: Virtual DP Sink (Internal Display Panel)
If the output port has
- DPCD rev. >= DP 1.4
- port_num >= 8

In this case, DSC can only be attempted on the peer device (the output port)

Case 4: Synaptix Workaround
If the output has
- link DPCD rev. >= DP 1.4
- link branch_dev_id = 0x90CC24 (Synaptix)
- There is exactly one branch device between the link and output

In this case, DSC can be attempted, but only using the *link* aux device's caps. This is a quirk.

Test for these cases as modes are enumerated for an MST endpoint. We cannot do this during link attach because the dc_sink object will not have been created yet

If no DSC is attempted, zero the DSC caps

Cc Wenjing Liu <[email protected]>
Cc Nikola Cornij <[email protected]>
---
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 123 +++++++++++++++++-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |   3 +
 2 files changed, 125 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +43 -0
index 16218a202b59..58571844f6d5 100644
@@ -25,6 +25,7 @@
 
 #include <linux/version.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_mst_helper.h>
 #include "dm_services.h"
 #include "amdgpu.h"
 #include "amdgpu_dm.h"
@@ -189,6 +190,120 @@ static const struct drm_connector_funcs
 dm_dp_mst_connector_funcs = {
 	.early_unregister = amdgpu_dm_mst_connector_early_unregister,
 };
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port)
+{
+	struct drm_dp_mst_port *downstream_port;
+
+	if (!port)
+		return false;
+
+	if (port->port_num >= 8 &&
+		port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* Virtual DP Sink (Internal Display Panel) */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
+			!port->mcs &&
+			port->ldps &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-HDMI Protocol Converter */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
+			port->mstb &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-DP */
+		if (port->mstb->num_ports == 2) {
+			list_for_each_entry(downstream_port, &port->mstb-
 >ports, next) {
+				if (!downstream_port->input &&
+						downstream_port->pdt ==
 DP_PEER_DEVICE_SST_SINK)
+					return true;
+			}
+		}
+	}
+	return false;
+}
+
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector)
+{
+	struct drm_dp_mst_port *port = aconnector->port;
+	struct dc_link *link = aconnector->dc_sink->link;
+	u8 down_stream_port_data;
+
+	if (port->mgr->mst_primary == port->parent &&
+			link->dpcd_caps.branch_dev_id == 0x90CC24 &&
+			link->dpcd_caps.dpcd_rev.raw >= DP_DPCD_REV_14) {
+		drm_dp_mst_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT,

&down_stream_port_data, 1);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +8 -0
+		if ((down_stream_port_data & 7) != 3)
+			return true;
+	}
+	return false;
+}
+
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static bool validate_dsc_caps_on_connector(struct amdgpu_dm_connector

*aconnector)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +11 -0
+{
+	u8 upstream_dsc_caps[16] = { 0 };
+	u8 endpoint_dsc_caps[16] = { 0 };
+	u8 endpoint_fec_caps = 0;
+	struct dc_sink *dc_sink = aconnector->dc_sink;
+	struct drm_dp_mst_port *output_port = aconnector->port;
+	struct drm_dp_mst_port *immediate_upstream_port;
+	struct drm_dp_mst_port *fec_port;
+
+	if (aconnector->port && aconnector->port->parent)
+		immediate_upstream_port = aconnector->port->parent-
Quoted 1 line

port_parent;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +13 -0
+	else
+		immediate_upstream_port = NULL;
+
+	fec_port = immediate_upstream_port;
+	while (fec_port) {
+		if (!fec_port->fec_capable)
+			return false;
+
+		fec_port = fec_port->parent->port_parent;
+	}
+
+	if (immediate_upstream_port)
+		drm_dp_mst_dpcd_read(&immediate_upstream_port->aux,

DP_DSC_SUPPORT, upstream_dsc_caps, 16);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -0
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_DSC_SUPPORT,

endpoint_dsc_caps, 16);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -0
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_FEC_CAPABILITY,

&endpoint_fec_caps, 1);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 -0
+
+	if (is_virtual_dpcd(immediate_upstream_port)
+			&& (upstream_dsc_caps[0] & 0x2) /* DSC passthrough

capability */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +2 -0
+			&& (endpoint_fec_caps & DP_FEC_CAPABLE)
+			&& (endpoint_dsc_caps[0] &

DP_DSC_DECOMPRESSION_IS_SUPPORTED)) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +2 -0
+		/* Enpoint decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink-
Quoted 1 line

sink_dsc_caps.dsc_dec_caps))

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +6 -0
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = false;
+	} else if (is_virtual_dpcd(immediate_upstream_port)) {
+		/* Virtual DPCD decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink-
Quoted 1 line

sink_dsc_caps.dsc_dec_caps))

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +5 -0
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (is_virtual_dpcd(output_port)) {
+		/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP

Sink */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -0
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink-
Quoted 1 line

sink_dsc_caps.dsc_dec_caps))

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +7 -0
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (synaptix_workaround(aconnector)) {
+		/* Synaptix workaround */
+		aconnector = dc_sink->link->priv;
+		drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, DP_DSC_SUPPORT,

upstream_dsc_caps, 16);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -0
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink-
Quoted 1 line

sink_dsc_caps.dsc_dec_caps))

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +11 -0
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else {
+		return false;
+	}
+
+	return true;
+}
+#endif
+
 static int dm_dp_mst_get_modes(struct drm_connector *connector)
 {
 	struct amdgpu_dm_connector *aconnector =

to_amdgpu_dm_connector(connector);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +7 -1
@@ -231,10 +346,16 @@ static int dm_dp_mst_get_modes(struct drm_connector
 *connector)
 		/* dc_link_add_remote_sink returns a new reference */
 		aconnector->dc_sink = dc_sink;
 
-		if (aconnector->dc_sink)
+		if (aconnector->dc_sink) {
 			amdgpu_dm_update_freesync_caps(
 					connector, aconnector->edid);
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+			if (!validate_dsc_caps_on_connector(aconnector))
+				memset(&aconnector->dc_sink->sink_dsc_caps,
+				       0, sizeof(aconnector->dc_sink-
 >sink_dsc_caps));
+#endif
+		}
 	}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +0 -0
 	drm_connector_update_edid_property(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +3 -0
index 2da851b40042..8de3d8c30f8d 100644
@@ -32,4 +32,7 @@ struct amdgpu_dm_connector;
 void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
 				       struct amdgpu_dm_connector
 *aconnector);
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port);
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector);
+

#endif

Signature · 7 lines
Cheers,
	Lyude Paul

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

Re: [PATCH v2 11/14] drm/amd/display: Validate DSC caps on MST endpoints

In reply to a message not in the archive
Quoted 49 lines · David Francis

The first step in MST DSC is checking MST endpoints to see how DSC can be enabled

Case 1: DP-to-DP peer device
if the branch immediately upstream has
- PDT = DP_PEER_DEVICE_DP_MST_BRANCHING (2)
- DPCD rev. >= DP 1.4
- Exactly one input and one output
- The output has PDT = DP_PEER_DEVICE_SST_SINK (3)

In this case, DSC could be possible either on the endpoint
or the peer device. Prefer the endpoint, which is possible if
- The endpoint has DP_DSC_DECOMPRESSION_IS_SUPPORTED bit set
- The endpoint has DP_FEC_CAPABLE bit set
- The peer device has DSC_PASSTHROUGH_CAPABILITY bit set (from DP v2.0)

Otherwise, use the peer device

Case 2: DP-to-HDMI peer device
If the output port has
- PDT = DP_PEER_DEVICE_DP_LEGACY_CONV (4)
- DPCD rev. >= DP 1.4
- LDPS = true
- MCS = false

In this case, DSC can only be attempted on the peer device (the output port)

Case 3: Virtual DP Sink (Internal Display Panel)
If the output port has
- DPCD rev. >= DP 1.4
- port_num >= 8

In this case, DSC can only be attempted on the peer device (the output port)

Case 4: Synaptix Workaround
If the output has
- link DPCD rev. >= DP 1.4
- link branch_dev_id = 0x90CC24 (Synaptix)
- There is exactly one branch device between the link and output

In this case, DSC can be attempted, but only using the *link* aux device's caps. This is a quirk.

Test for these cases as modes are enumerated for an MST endpoint. We cannot do this during link attach because the dc_sink object will not have been created yet

Quoted 5 lines

If no DSC is attempted, zero the DSC caps

Cc Wenjing Liu <[email protected]>
Cc Nikola Cornij <[email protected]>

Questions and comments below...

Quoted 20 lines
---
  .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 123 +++++++++++++++++-
  .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |   3 +
  2 files changed, 125 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -0
index 16218a202b59..58571844f6d5 100644
@@ -25,6 +25,7 @@
 
  #include <linux/version.h>
  #include <drm/drm_atomic_helper.h>
+#include <drm/drm_dp_mst_helper.h>
  #include "dm_services.h"
  #include "amdgpu.h"
  #include "amdgpu_dm.h"
@@ -189,6 +190,120 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = {
  	.early_unregister = amdgpu_dm_mst_connector_early_unregister,
  };

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { · line 201

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +9 -0
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port)
+{
+	struct drm_dp_mst_port *downstream_port;
+
+	if (!port)
+		return false;
+
+	if (port->port_num >= 8 &&
+		port->dpcd_rev >= DP_DPCD_REV_14) {

All these if statements should be aligned if possible. That's just formatting nitpicks though.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { · line 214

Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +13 -0
+		/* Virtual DP Sink (Internal Display Panel) */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
+			!port->mcs &&
+			port->ldps &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-HDMI Protocol Converter */
+		return true;
+	} else if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
+			port->mstb &&
+			port->dpcd_rev >= DP_DPCD_REV_14) {
+		/* DP-to-DP */
+		if (port->mstb->num_ports == 2) {

Can probably merge this if condition into the else if above. Will help cut down on line length below.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { · line 225

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +10 -0
+			list_for_each_entry(downstream_port, &port->mstb->ports, next) {
+				if (!downstream_port->input &&
+						downstream_port->pdt == DP_PEER_DEVICE_SST_SINK)
+					return true;
+			}
+		}
+	}
+	return false;
+} > +
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector)

This probably needs a better name. This isn't applying a workaround for a specific device but returning true if it is a specific device.

Quoted 70 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +70 -0
+{
+	struct drm_dp_mst_port *port = aconnector->port;
+	struct dc_link *link = aconnector->dc_sink->link;
+	u8 down_stream_port_data;
+
+	if (port->mgr->mst_primary == port->parent &&
+			link->dpcd_caps.branch_dev_id == 0x90CC24 &&
+			link->dpcd_caps.dpcd_rev.raw >= DP_DPCD_REV_14) {
+		drm_dp_mst_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT, &down_stream_port_data, 1);
+		if ((down_stream_port_data & 7) != 3)
+			return true;
+	}
+	return false;
+}
+
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static bool validate_dsc_caps_on_connector(struct amdgpu_dm_connector *aconnector)
+{
+	u8 upstream_dsc_caps[16] = { 0 };
+	u8 endpoint_dsc_caps[16] = { 0 };
+	u8 endpoint_fec_caps = 0;
+	struct dc_sink *dc_sink = aconnector->dc_sink;
+	struct drm_dp_mst_port *output_port = aconnector->port;
+	struct drm_dp_mst_port *immediate_upstream_port;
+	struct drm_dp_mst_port *fec_port;
+
+	if (aconnector->port && aconnector->port->parent)
+		immediate_upstream_port = aconnector->port->parent->port_parent;
+	else
+		immediate_upstream_port = NULL;
+
+	fec_port = immediate_upstream_port;
+	while (fec_port) {
+		if (!fec_port->fec_capable)
+			return false;
+
+		fec_port = fec_port->parent->port_parent;
+	}
+
+	if (immediate_upstream_port)
+		drm_dp_mst_dpcd_read(&immediate_upstream_port->aux, DP_DSC_SUPPORT, upstream_dsc_caps, 16);
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_DSC_SUPPORT, endpoint_dsc_caps, 16);
+	drm_dp_mst_dpcd_read(&output_port->aux, DP_FEC_CAPABILITY, &endpoint_fec_caps, 1);
+
+	if (is_virtual_dpcd(immediate_upstream_port)
+			&& (upstream_dsc_caps[0] & 0x2) /* DSC passthrough capability */
+			&& (endpoint_fec_caps & DP_FEC_CAPABLE)
+			&& (endpoint_dsc_caps[0] & DP_DSC_DECOMPRESSION_IS_SUPPORTED)) {
+		/* Enpoint decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = false;
+	} else if (is_virtual_dpcd(immediate_upstream_port)) {
+		/* Virtual DPCD decompression with DP-to-DP peer device */
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (is_virtual_dpcd(output_port)) {
+		/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
+		if (!dc_dsc_parse_dsc_dpcd(endpoint_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else if (synaptix_workaround(aconnector)) {
+		/* Synaptix workaround */
+		aconnector = dc_sink->link->priv;
+		drm_dp_dpcd_read(&aconnector->dm_dp_aux.aux, DP_DSC_SUPPORT, upstream_dsc_caps, 16);
+		if (!dc_dsc_parse_dsc_dpcd(upstream_dsc_caps, NULL, &dc_sink->sink_dsc_caps.dsc_dec_caps))

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { · line 305

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +10 -0
+			return false;
+
+		dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc = true;
+	} else {
+		return false;
+	}
+
+	return true;
+}
+#endif

Should this be common code instead as a dp mst helper for determining caps? Other than setting the dc sink stuff the rest looks like it could be common but I'm not overly familiar with the architecture.

Quoted 27 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +8 -1
+
  static int dm_dp_mst_get_modes(struct drm_connector *connector)
  {
  	struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
@@ -231,10 +346,16 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
  		/* dc_link_add_remote_sink returns a new reference */
  		aconnector->dc_sink = dc_sink;
 
-		if (aconnector->dc_sink)
+		if (aconnector->dc_sink) {
  			amdgpu_dm_update_freesync_caps(
  					connector, aconnector->edid);
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+			if (!validate_dsc_caps_on_connector(aconnector))
+				memset(&aconnector->dc_sink->sink_dsc_caps,
+				       0, sizeof(aconnector->dc_sink->sink_dsc_caps));
+#endif
+		}
  	}
 
  	drm_connector_update_edid_property(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +0 -0
index 2da851b40042..8de3d8c30f8d 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h struct amdgpu_dm_connector; · line 36

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +2 -0
@@ -32,4 +32,7 @@ struct amdgpu_dm_connector;
  void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
  				       struct amdgpu_dm_connector *aconnector);
 
+bool is_virtual_dpcd(struct drm_dp_mst_port *port);
+bool synaptix_workaround(struct amdgpu_dm_connector *aconnector);

These shouldn't be defined in the header if they're only going to be used here, they should just be static.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h struct amdgpu_dm_connector; · line 38

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +1 -0
+
  #endif

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

#23 lore raw

PATCH v2 12/14 drm/amd/display: Write DSC enable to MST DPCD

In reply to a message not in the archive

Rework the dm_helpers_write_dsc_enable callback to handle the MST case

Depending on how DSC is done, the DP_DSC_ENABLE bit needs to be set on a different point

For SST, use the link aux

For endpoint DSC over DP-to-DP peer devices, use the output port

For peer device DSC over DP-to-DP peer devices, use the upstream (peer) device

For DP-to-HDMI or virtual DP peer devices, use the output port

For the Synaptix workaround, use the link aux

Cc Wenjing Liu <[email protected]>
Cc Nikola Cornij <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +29 -1
index dfa99e0d6e64..62731c2bf2bf 100644
@@ -38,6 +38,7 @@
 #include "dc.h"
 #include "amdgpu_dm.h"
 #include "amdgpu_dm_irq.h"
+#include "amdgpu_dm_mst_types.h"
 
 #include "dm_helpers.h"
 
@@ -556,8 +557,35 @@ bool dm_helpers_dp_write_dsc_enable(
 )
 {
 	uint8_t enable_dsc = enable ? 1 : 0;
+	struct amdgpu_dm_connector *aconnector;
+
+	if (!stream)
+		return false;
+
+	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+
+		if (!aconnector || !aconnector->dc_sink)
+			return false;
+
+		if (!aconnector->dc_sink->sink_dsc_caps.is_virtual_dpcd_dsc)
+			return drm_dp_mst_dpcd_write(&aconnector->port->aux,
+						    DP_DSC_ENABLE, &enable_dsc, 1) >= 0;
+		else if (is_virtual_dpcd(aconnector->port->parent->port_parent))
+			return drm_dp_mst_dpcd_write(&aconnector->port->parent->port_parent->aux,
+						    DP_DSC_ENABLE, &enable_dsc, 1) >= 0;
+		else if (is_virtual_dpcd(aconnector->port))
+			return drm_dp_mst_dpcd_write(&aconnector->port->aux,
+						    DP_DSC_ENABLE, &enable_dsc, 1) >= 0;
+		else if (synaptix_workaround(aconnector))
+			return dm_helpers_dp_write_dpcd(ctx, stream->link,
+						DP_DSC_ENABLE, &enable_dsc, 1);
+	}
+
+	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT)
+		return dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1);
 
-	return dm_helpers_dp_write_dpcd(ctx, stream->sink->link, DP_DSC_ENABLE, &enable_dsc, 1);
+	return false;
 }
 #endif
 
Signature · 6 lines
2.17.1

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

PATCH v2 13/14 drm/amd/display: MST DSC compute fair share

In reply to a message not in the archive

If there is limited link bandwidth on a MST network, it must be divided fairly between the streams on that network

Implement an algorithm to determine the correct DSC config for each stream

The algorithm:
This
[ ] ( )
represents the range of bandwidths possible for a given stream. The [] area represents the range of DSC configs, and the () represents no DSC. The bandwidth used increases from left to right.

First, try disabling DSC on all streams
[ ] (|)
[ ] (|)
Check this against the bandwidth limits of the link and each branch (including each endpoint). If it passes, the job is done

Second, try maximum DSC compression on all streams that support DSC
[| ] ( )
[| ] ( )
If this does not pass, then enabling this combination of streams is impossible

Otherwise, divide the remaining bandwidth evenly amongst the streams
[ | ] ( )
[ | ] ( )

If one or more of the streams reach minimum compression, evenly divide the reamining bandwidth amongst the remaining streams
[ |] ( )
[ |] ( )
[ | ] ( )
[ | ] ( )

If all streams can reach minimum compression, disable compression greedily

     [      |]  ( )
     [        |]    ( )
     [                 ]                                (|)

Perform this algorithm on each full update, on each MST link with at least one DSC stream on it

After the configs are computed, call dcn20_add_dsc_to_stream_resource on each stream with DSC enabled. It is only after all streams are created that we can know which of them will need DSC.

Do all of this at the end of amdgpu atomic check. If it fails, fail check; This combination of timings cannot be supported.

Cc Wenjing Liu <[email protected]>
Cc Nikola Cornij <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   4 +
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 375 ++++++++++++++++++
 .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |   4 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |   7 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.h |   1 +
 5 files changed, 388 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
index 84249057e181..145fd73025dc 100644
@@ -7331,6 +7331,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		if (ret)
 			goto fail;
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+		if (!compute_mst_dsc_configs_for_state(dm_state->context))
+			goto fail;
+#endif
 		if (dc_validate_global_state(dc, dm_state->context, false) != DC_OK) {
 			ret = -EINVAL;
 			goto fail;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +375 -0

384 lines not on this page · raw message

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +3 -1
index 8de3d8c30f8d..b7d2e4e70185 100644
@@ -34,5 +34,7 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
 
 bool is_virtual_dpcd(struct drm_dp_mst_port *port);
 bool synaptix_workaround(struct amdgpu_dm_connector *aconnector);
-
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+bool compute_mst_dsc_configs_for_state(struct dc_state *dc_state);
+#endif
 #endif
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +5 -2
index c59f31dcdc0d..22511b047837 100644
@@ -1439,7 +1439,7 @@ static void release_dsc(struct resource_context *res_ctx,
 
 
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
-static enum dc_status add_dsc_to_stream_resource(struct dc *dc,
+enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc,
 		struct dc_state *dc_ctx,
 		struct dc_stream_state *dc_stream)
 {
@@ -1454,6 +1454,9 @@ static enum dc_status add_dsc_to_stream_resource(struct dc *dc,
 		if (pipe_ctx->stream != dc_stream)
 			continue;
 
+		if (pipe_ctx->stream_res.dsc)
+			continue;
+
 		acquire_dsc(&dc_ctx->res_ctx, pool, &pipe_ctx->stream_res.dsc);
 
 		/* The number of DSCs can be less than the number of pipes */
@@ -1511,7 +1514,7 @@ enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx,
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
 	/* Get a DSC if required and available */
 	if (result == DC_OK && dc_stream->timing.flags.DSC)
-		result = add_dsc_to_stream_resource(dc, new_ctx, dc_stream);
+		result = dcn20_add_dsc_to_stream_resource(dc, new_ctx, dc_stream);
 #endif
 
 	if (result == DC_OK)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h +1 -0
index 44f95aa0d61e..2209ebda6ef6 100644
@@ -131,6 +131,7 @@ void dcn20_calculate_dlg_params(
 
 enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
 enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
+enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc, struct dc_state *dc_ctx, struct dc_stream_state *dc_stream);
 enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
 enum dc_status dcn20_get_default_swizzle_mode(struct dc_plane_state *plane_state);
 
Signature · 6 lines
2.17.1

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

PATCH v2 3/14 Revert "drm/amd/display: add global master update lock for DCN2"

In reply to David Francis

This reverts commit 55a6f5bbcf00a49565946c0a9b8c716313dc6c05.

This commit was accidentally promoted twice

---
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c    |  4 --
 .../gpu/drm/amd/display/dc/dcn20/dcn20_optc.c | 63 +------------------
 .../gpu/drm/amd/display/dc/dcn20/dcn20_optc.h |  3 -
 .../amd/display/dc/inc/hw/timing_generator.h  |  2 -
 4 files changed, 1 insertion(+), 71 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +0 -4
index fa8a73f6c8e3..e146d1d8d45e 100644
@@ -575,10 +575,6 @@ enum dc_status dcn20_enable_stream_timing(
 			pipe_ctx->stream->signal,
 			true);
 
-	if (pipe_ctx->stream_res.tg->funcs->setup_global_lock)
-		pipe_ctx->stream_res.tg->funcs->setup_global_lock(
-				pipe_ctx->stream_res.tg);
-
 	if (odm_pipe)
 		odm_pipe->stream_res.opp->funcs->opp_pipe_clock_control(
 				odm_pipe->stream_res.opp,
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c +1 -62

76 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.h +0 -3
index 47cb4de1564c..32a58431fd09 100644
@@ -106,9 +106,6 @@ void optc2_get_optc_source(struct timing_generator *optc,
 
 void optc2_triplebuffer_lock(struct timing_generator *optc);
 void optc2_triplebuffer_unlock(struct timing_generator *optc);
-void optc2_lock(struct timing_generator *optc);
-void optc2_lock_global(struct timing_generator *optc);
-void optc2_setup_global_lock(struct timing_generator *optc);
 void optc2_lock_doublebuffer_disable(struct timing_generator *optc);
 void optc2_lock_doublebuffer_enable(struct timing_generator *optc);
 void optc2_program_manual_trigger(struct timing_generator *optc);
drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h +0 -2
index f607ef24c766..e0713d6d6c8d 100644
@@ -189,10 +189,8 @@ struct timing_generator_funcs {
 	bool (*did_triggered_reset_occur)(struct timing_generator *tg);
 	void (*setup_global_swap_lock)(struct timing_generator *tg,
 							const struct dcp_gsl_params *gsl_params);
-	void (*setup_global_lock)(struct timing_generator *tg);
 	void (*unlock)(struct timing_generator *tg);
 	void (*lock)(struct timing_generator *tg);
-	void (*lock_global)(struct timing_generator *tg);
 	void (*lock_doublebuffer_disable)(struct timing_generator *tg);
 	void (*lock_doublebuffer_enable)(struct timing_generator *tg);
 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
Signature · 6 lines
2.17.1

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

PATCH v2 4/14 Revert "drm/amd/display: Fix underscan not using proper scaling"

In reply to David Francis

This reverts commit 80e80ec817f161560b4159608fb41bd289abede3.

This commit fixed an issue with underscan commits not updating all needed timing values, but through various refactors it is no longer necessary. It causes corruption on odm combine by overwriting the halved h_active in the stream timing

---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -11
index 77ac7f707ec5..1189e320062b 100644
@@ -2127,7 +2127,7 @@ void dc_commit_updates_for_stream(struct dc *dc,
 	enum surface_update_type update_type;
 	struct dc_state *context;
 	struct dc_context *dc_ctx = dc->ctx;
-	int i, j;
+	int i;
 
 	stream_status = dc_stream_get_status(stream);
 	context = dc->current_state;
@@ -2165,16 +2165,6 @@ void dc_commit_updates_for_stream(struct dc *dc,
 
 		copy_surface_update_to_plane(surface, &srf_updates[i]);
 
-		if (update_type >= UPDATE_TYPE_MED) {
-			for (j = 0; j < dc->res_pool->pipe_count; j++) {
-				struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
-
-				if (pipe_ctx->plane_state != surface)
-					continue;
-
-				resource_build_scaling_params(pipe_ctx);
-			}
-		}
 	}
 
 	copy_stream_update_to_stream(dc, context, stream, stream_update);
Signature · 6 lines
2.17.1

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

PATCH v2 9/14 drm/dp-mst: Export symbols for dpcd read/write

In reply to David Francis

To use these functions in drm driver directories, they must be exported

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
index b40d975aec76..5d5bd42da17c 100644
@@ -1512,6 +1512,7 @@ ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_read(port->mgr, port,
 				     offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_read);
 
 /**
  * drm_dp_mst_dpcd_write() - write a series of bytes to the DPCD via sideband
@@ -1535,6 +1536,7 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_write(port->mgr, port,
 				      offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_write);
 
 static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
 {
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): 20190820191203.25807-10-David.Francis-5C7GfCeVMHo@public.gmane.org

#29 lore raw

Re: [PATCH v2 09/14] drm/dp-mst: Export symbols for dpcd read/write

[Added Leo Li here, since they did the auxdev work that introduced these functions]

Since it seems we'll actually be doing remote DPCD read/writes in DRM drivers and not just from auxdev, maybe we should combine drm_dp_dpcd_read() with drm_dp_mst_dpcd_read() and do the same with the _write() variants? Based on previous discussions with Leo Li I remember that we can't just combine the dp_aux_dev->transfer() callbacks in struct drm_dp_aux_dev, but I don't see a reason we can't just teach drm_dp_dpcd_read/write() to work with MST aux so that we don't need two seperate functions. This should be pretty easy to do, just:

/* Add a check like this at the start of drm_dp_dpcd_read(): */

ssize_t drm_dp_dpcd_read(...) {
	if (aux->is_remote)
		return drm_dp_mst_dpcd_read(...);

	/* ... */
}

/* And in drm_dp_dpcd_write(): */

ssize_t drm_dp_dpcd_write(...) {
	if (aux->is_remote)
		return drm_dp_mst_dpcd_write(...);

	/* ... */
}

Then just replace the manual calls to drm_dp_mst_dpcd_write() in drivers/gpu/drm/drm_dp_aux_dev.c with normal drm_dp_dpcd_read()/drm_dp_dpcd_write() calls. Thoughts?

Quoted 31 lines · David Francis

To use these functions in drm driver directories, they must be exported

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
index b40d975aec76..5d5bd42da17c 100644
@@ -1512,6 +1512,7 @@ ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_read(port->mgr, port,
 				     offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_read);
 
 /**
  * drm_dp_mst_dpcd_write() - write a series of bytes to the DPCD via

sideband

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
@@ -1535,6 +1536,7 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_write(port->mgr, port,
 				      offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_write);
 
 static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8
 *guid)

{

Signature · 7 lines
Cheers,
	Lyude Paul

_______________________________________________
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): 773c80494087854b72ffb85938f0ea54bd89c121.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#31 lore raw

Re: [PATCH v2 09/14] drm/dp-mst: Export symbols for dpcd read/write

Quoted 28 lines · Lyude Paul

[Added Leo Li here, since they did the auxdev work that introduced these functions]

Since it seems we'll actually be doing remote DPCD read/writes in DRM drivers and not just from auxdev, maybe we should combine drm_dp_dpcd_read() with drm_dp_mst_dpcd_read() and do the same with the _write() variants? Based on previous discussions with Leo Li I remember that we can't just combine the dp_aux_dev->transfer() callbacks in struct drm_dp_aux_dev, but I don't see a reason we can't just teach drm_dp_dpcd_read/write() to work with MST aux so that we don't need two seperate functions. This should be pretty easy to do, just:

/* Add a check like this at the start of drm_dp_dpcd_read(): */

ssize_t drm_dp_dpcd_read(...) {
	if (aux->is_remote)
		return drm_dp_mst_dpcd_read(...);

	/* ... */
}

/* And in drm_dp_dpcd_write(): */

ssize_t drm_dp_dpcd_write(...) {
	if (aux->is_remote)
		return drm_dp_mst_dpcd_write(...);

	/* ... */
}
Quoted 3 lines

Then just replace the manual calls to drm_dp_mst_dpcd_write() in drivers/gpu/drm/drm_dp_aux_dev.c with normal drm_dp_dpcd_read()/drm_dp_dpcd_write() calls. Thoughts?

I think this would work well.

drm_dp_mst_dpcd_read/write will eventually call drm_dp_dpcd_write, so doing so would cause a recursive call. That should be safe though. The mst manager's aux will be used, and that should always be a real (is_remote == false) aux, fwict.

Essentially, it's just moving that conditional from auxdev_read/write_iter to drm_dp_dpcd_read/write.

Leo

Quoted 30 lines · David Francis
Quoted 28 lines

To use these functions in drm driver directories, they must be exported

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
index b40d975aec76..5d5bd42da17c 100644
@@ -1512,6 +1512,7 @@ ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_read(port->mgr, port,
 				     offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_read);
 
 /**
  * drm_dp_mst_dpcd_write() - write a series of bytes to the DPCD via

sideband

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
@@ -1535,6 +1536,7 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
 	return drm_dp_send_dpcd_write(port->mgr, port,
 				      offset, size, buffer);
 }
+EXPORT_SYMBOL(drm_dp_mst_dpcd_write);
 
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8
 *guid)

{

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

#32 lore raw

PATCH v2 14/14 drm/amd/display: Trigger modesets on MST DSC connectors

In reply to David Francis

Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.

Therefore, whenever a crtc has drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and set mode_changed on its state

v2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs

Cc Leo Li <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +74 -0
index 145fd73025dc..e64f2a6eb71a 100644
@@ -6475,7 +6475,70 @@ static int do_aquire_global_lock(struct drm_device *dev,
 
 	return ret < 0 ? ret : 0;
 }
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state, struct drm_crtc *crtc)
+{
+	struct drm_connector *connector;
+	struct drm_connector_state *conn_state;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_crtc_state *new_crtc_state;
+	struct amdgpu_dm_connector *aconnector = NULL, *aconnector_to_add;
+	int i, j;
+	struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS] = { 0 };
+
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
+		if (conn_state->crtc != crtc)
+			continue;
+
+		aconnector = to_amdgpu_dm_connector(connector);
+		if (!aconnector->port)
+			aconnector = NULL;
+		else
+			break;
+	}
+
+	if (!aconnector)
+		return 0;
+
+	i = 0;
+	drm_connector_list_iter_begin(state->dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		if (!connector->state || !connector->state->crtc)
+			continue;
+
+		aconnector_to_add = to_amdgpu_dm_connector(connector);
+		if (!aconnector_to_add->port)
+			continue;
+
+		if (aconnector_to_add->port->mgr != aconnector->port->mgr)
+			continue;
 
+		if (!aconnector_to_add->dc_sink)
+			continue;
+
+		if (!aconnector_to_add->dc_sink->sink_dsc_caps.dsc_dec_caps.is_dsc_supported)
+			continue;
+
+		if (i >= AMDGPU_MAX_CRTCS)
+			continue;
+
+		crtcs_affected[i] = connector->state->crtc;
+		i++;
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	for (j = 0; j < i; j++) {
+		new_crtc_state = drm_atomic_get_crtc_state(state, crtcs_affected[j]);
+		if (IS_ERR(new_crtc_state))
+			return PTR_ERR(new_crtc_state);
+
+		new_crtc_state->mode_changed = true;
+	}
+
+	return 0;
+
+}
+#endif
 static void get_freesync_config_for_crtc(
 	struct dm_crtc_state *new_crtc_state,
 	struct dm_connector_state *new_con_state)
@@ -7160,6 +7223,17 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	if (ret)
 		goto fail;
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+	if (adev->asic_type >= CHIP_NAVI10) {
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+			if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
+				ret = add_affected_mst_dsc_crtcs(state, crtc);
+				if (ret)
+					goto fail;
+			}
+		}
+	}
+#endif
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
 		    !new_crtc_state->color_mgmt_changed &&
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): 20190820191203.25807-15-David.Francis-5C7GfCeVMHo@public.gmane.org

#34 lore raw

Re: [PATCH v2 14/14] drm/amd/display: Trigger modesets on MST DSC connectors

This should definitely be implemented as an atomic helper in drm_dp_mst_topology.c as well.

Quoted 122 lines · David Francis

Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.

Therefore, whenever a crtc has drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and set mode_changed on its state

v2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs

Cc Leo Li <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +53 -0
index 145fd73025dc..e64f2a6eb71a 100644
@@ -6475,7 +6475,70 @@ static int do_aquire_global_lock(struct drm_device
 *dev,
 
 	return ret < 0 ? ret : 0;
 }
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state,
 struct drm_crtc *crtc)
+{
+	struct drm_connector *connector;
+	struct drm_connector_state *conn_state;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_crtc_state *new_crtc_state;
+	struct amdgpu_dm_connector *aconnector = NULL, *aconnector_to_add;
+	int i, j;
+	struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS] = { 0 };
+
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
+		if (conn_state->crtc != crtc)
+			continue;
+
+		aconnector = to_amdgpu_dm_connector(connector);
+		if (!aconnector->port)
+			aconnector = NULL;
+		else
+			break;
+	}
+
+	if (!aconnector)
+		return 0;
+
+	i = 0;
+	drm_connector_list_iter_begin(state->dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		if (!connector->state || !connector->state->crtc)
+			continue;
+
+		aconnector_to_add = to_amdgpu_dm_connector(connector);
+		if (!aconnector_to_add->port)
+			continue;
+
+		if (aconnector_to_add->port->mgr != aconnector->port->mgr)
+			continue;
 
+		if (!aconnector_to_add->dc_sink)
+			continue;
+
+		if (!aconnector_to_add->dc_sink-
 >sink_dsc_caps.dsc_dec_caps.is_dsc_supported)
+			continue;
+
+		if (i >= AMDGPU_MAX_CRTCS)
+			continue;
+
+		crtcs_affected[i] = connector->state->crtc;
+		i++;
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	for (j = 0; j < i; j++) {
+		new_crtc_state = drm_atomic_get_crtc_state(state,

crtcs_affected[j]);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +21 -0
+		if (IS_ERR(new_crtc_state))
+			return PTR_ERR(new_crtc_state);
+
+		new_crtc_state->mode_changed = true;
+	}
+
+	return 0;
+
+}
+#endif
 static void get_freesync_config_for_crtc(
 	struct dm_crtc_state *new_crtc_state,
 	struct dm_connector_state *new_con_state)
@@ -7160,6 +7223,17 @@ static int amdgpu_dm_atomic_check(struct drm_device
 *dev,
 	if (ret)
 		goto fail;
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+	if (adev->asic_type >= CHIP_NAVI10) {
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
 new_crtc_state, i) {
+			if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
+				ret = add_affected_mst_dsc_crtcs(state, crtc);
+				if (ret)
+					goto fail;
+			}
+		}
+	}
+#endif
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,

new_crtc_state, i) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
 		    !new_crtc_state->color_mgmt_changed &&
Signature · 7 lines
Cheers,
	Lyude Paul

_______________________________________________
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): f7272de2841c61f1297f0fce493efe5dd5317dfa.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#36 lore raw

Re: [PATCH v2 14/14] drm/amd/display: Trigger modesets on MST DSC connectors

Quoted 2 lines · Lyude Paul

This should definitely be implemented as an atomic helper in drm_dp_mst_topology.c as well.

This is probably reasonable, most drivers would probably want this.

The issues with this in general are still:

(1) Knowing if you have a DSC in the MST network to decide when to do this

(2) Marking the CRTCs for the connectors in the MST chain as having their mode changed while iterating over the connectors

For amdgpu it's "acceptable" based on other design constraints to just lock and grab everything on a modeset but this may not be true for every driver.

Nicholas Kazlauskas

Quoted 108 lines · David Francis
Quoted 106 lines

Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.

Therefore, whenever a crtc has drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and set mode_changed on its state

v2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs

Cc Leo Li <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 74 +++++++++++++++++++
  1 file changed, 74 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +53 -0
index 145fd73025dc..e64f2a6eb71a 100644
@@ -6475,7 +6475,70 @@ static int do_aquire_global_lock(struct drm_device
 *dev,
 
  	return ret < 0 ? ret : 0;
  }
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state,
 struct drm_crtc *crtc)
+{
+	struct drm_connector *connector;
+	struct drm_connector_state *conn_state;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_crtc_state *new_crtc_state;
+	struct amdgpu_dm_connector *aconnector = NULL, *aconnector_to_add;
+	int i, j;
+	struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS] = { 0 };
+
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
+		if (conn_state->crtc != crtc)
+			continue;
+
+		aconnector = to_amdgpu_dm_connector(connector);
+		if (!aconnector->port)
+			aconnector = NULL;
+		else
+			break;
+	}
+
+	if (!aconnector)
+		return 0;
+
+	i = 0;
+	drm_connector_list_iter_begin(state->dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		if (!connector->state || !connector->state->crtc)
+			continue;
+
+		aconnector_to_add = to_amdgpu_dm_connector(connector);
+		if (!aconnector_to_add->port)
+			continue;
+
+		if (aconnector_to_add->port->mgr != aconnector->port->mgr)
+			continue;
 
+		if (!aconnector_to_add->dc_sink)
+			continue;
+
+		if (!aconnector_to_add->dc_sink-
 > sink_dsc_caps.dsc_dec_caps.is_dsc_supported)
+			continue;
+
+		if (i >= AMDGPU_MAX_CRTCS)
+			continue;
+
+		crtcs_affected[i] = connector->state->crtc;
+		i++;
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	for (j = 0; j < i; j++) {
+		new_crtc_state = drm_atomic_get_crtc_state(state,

crtcs_affected[j]);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -0
+		if (IS_ERR(new_crtc_state))
+			return PTR_ERR(new_crtc_state);
+
+		new_crtc_state->mode_changed = true;
+	}
+
+	return 0;
+
+}
+#endif
  static void get_freesync_config_for_crtc(
  	struct dm_crtc_state *new_crtc_state,
  	struct dm_connector_state *new_con_state)
@@ -7160,6 +7223,17 @@ static int amdgpu_dm_atomic_check(struct drm_device
 *dev,
  	if (ret)
  		goto fail;
 
Quoted 16 lines
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11 -0
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+	if (adev->asic_type >= CHIP_NAVI10) {
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
 new_crtc_state, i) {
+			if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
+				ret = add_affected_mst_dsc_crtcs(state, crtc);
+				if (ret)
+					goto fail;
+			}
+		}
+	}
+#endif
  	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
Quoted 3 lines

new_crtc_state, i) {
if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
!new_crtc_state->color_mgmt_changed &&

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