All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 0/6] DSC MST support in DRM
@ 2019-08-26 18:05 David Francis
  2019-08-26 18:05 ` [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes David Francis
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: David Francis

Add necessary support for MST DSC.
(Display Stream Compression over Multi-Stream Transport)

v4: Split patchset and rebase onto drm-tip
v5: Clean up formatting, make new quirk
v6: Fix typo, split last patch in two
v7: Fix compilation warnings
v8: Fix a missing mutex_unlock

David Francis (6):
  drm/dp_mst: Add PBN calculation for DSC modes
  drm/dp_mst: Parse FEC capability on MST ports
  drm/dp_mst: Add MST support to DP DPCD R/W functions
  drm/dp_mst: Fill branch->num_ports
  drm/dp_mst: Add new quirk for Synaptics MST hubs
  drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux

 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |   2 +-
 drivers/gpu/drm/drm_dp_aux_dev.c              |  12 +-
 drivers/gpu/drm/drm_dp_helper.c               |  32 +++-
 drivers/gpu/drm/drm_dp_mst_topology.c         | 172 +++++++++++++++++-
 drivers/gpu/drm/i915/display/intel_dp_mst.c   |   2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c       |   2 +-
 drivers/gpu/drm/radeon/radeon_dp_mst.c        |   2 +-
 include/drm/drm_dp_helper.h                   |   7 +
 include/drm/drm_dp_mst_helper.h               |   8 +-
 9 files changed, 209 insertions(+), 30 deletions(-)

-- 
2.17.1

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 18:36   ` Harry Wentland
  2019-08-26 18:05 ` [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports David Francis
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: nouveau, David Francis, intel-gfx, amd-gfx

With DSC, bpp can be fractional in multiples of 1/16.

Change drm_dp_calc_pbn_mode to reflect this, adding a new
parameter bool dsc. When this parameter is true, treat the
bpp parameter as having units not of bits per pixel, but
1/16 of a bit per pixel

v2: Don't add separate function for this

Cc: amd-gfx@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c    |  2 +-
 drivers/gpu/drm/drm_dp_mst_topology.c            | 16 ++++++++++++----
 drivers/gpu/drm/i915/display/intel_dp_mst.c      |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c          |  2 +-
 drivers/gpu/drm/radeon/radeon_dp_mst.c           |  2 +-
 include/drm/drm_dp_mst_helper.h                  |  3 +--
 6 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index a0ed0154a9f0..abafb5221b44 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -235,7 +235,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 
 		/* TODO need to know link rate */
 
-		pbn = drm_dp_calc_pbn_mode(clock, bpp);
+		pbn = drm_dp_calc_pbn_mode(clock, bpp, false);
 
 		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
 		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 82add736e17d..3e7b7553cf4d 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3534,10 +3534,11 @@ EXPORT_SYMBOL(drm_dp_check_act_status);
  * drm_dp_calc_pbn_mode() - Calculate the PBN for a mode.
  * @clock: dot clock for the mode
  * @bpp: bpp for the mode.
+ * @dsc: DSC mode. If true, bpp has units of 1/16 of a bit per pixel
  *
  * This uses the formula in the spec to calculate the PBN value for a mode.
  */
-int drm_dp_calc_pbn_mode(int clock, int bpp)
+int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc)
 {
 	u64 kbps;
 	s64 peak_kbps;
@@ -3555,11 +3556,18 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)
 	 * peak_kbps *= (1006/1000)
 	 * peak_kbps *= (64/54)
 	 * peak_kbps *= 8    convert to bytes
+	 *
+	 * If the bpp is in units of 1/16, further divide by 16. Put this
+	 * factor in the numerator rather than the denominator to avoid
+	 * integer overflow
 	 */
 
 	numerator = 64 * 1006;
 	denominator = 54 * 8 * 1000 * 1000;
 
+	if (dsc)
+		numerator /= 16;
+
 	kbps *= numerator;
 	peak_kbps = drm_fixp_from_fraction(kbps, denominator);
 
@@ -3570,19 +3578,19 @@ EXPORT_SYMBOL(drm_dp_calc_pbn_mode);
 static int test_calc_pbn_mode(void)
 {
 	int ret;
-	ret = drm_dp_calc_pbn_mode(154000, 30);
+	ret = drm_dp_calc_pbn_mode(154000, 30, false);
 	if (ret != 689) {
 		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
 				154000, 30, 689, ret);
 		return -EINVAL;
 	}
-	ret = drm_dp_calc_pbn_mode(234000, 30);
+	ret = drm_dp_calc_pbn_mode(234000, 30, false);
 	if (ret != 1047) {
 		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
 				234000, 30, 1047, ret);
 		return -EINVAL;
 	}
-	ret = drm_dp_calc_pbn_mode(297000, 24);
+	ret = drm_dp_calc_pbn_mode(297000, 24, false);
 	if (ret != 1063) {
 		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
 				297000, 24, 1063, ret);
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 2c5ac3dd647f..4f17f61f4453 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -61,7 +61,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
 		crtc_state->pipe_bpp = bpp;
 
 		crtc_state->pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock,
-						       crtc_state->pipe_bpp);
+						       crtc_state->pipe_bpp, false);
 
 		slots = drm_dp_atomic_find_vcpi_slots(state, &intel_dp->mst_mgr,
 						      port, crtc_state->pbn);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 5c36c75232e6..c68783c1f3fa 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -782,7 +782,7 @@ nv50_msto_atomic_check(struct drm_encoder *encoder,
 			const int bpp = connector->display_info.bpc * 3;
 			const int clock = crtc_state->adjusted_mode.clock;
 
-			asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp);
+			asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp, false);
 		}
 
 		slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr,
diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 2994f07fbad9..c997f88218f2 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -514,7 +514,7 @@ static bool radeon_mst_mode_fixup(struct drm_encoder *encoder,
 
 	mst_enc = radeon_encoder->enc_priv;
 
-	mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp);
+	mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp, false);
 
 	mst_enc->primary->active_device = mst_enc->primary->devices & mst_enc->connector->devices;
 	DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for encoder %d\n",
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 2ba6253ea6d3..9116b2c95239 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -610,8 +610,7 @@ bool drm_dp_mst_port_has_audio(struct drm_dp_mst_topology_mgr *mgr,
 struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
 
 
-int drm_dp_calc_pbn_mode(int clock, int bpp);
-
+int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
 
 bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
 			      struct drm_dp_mst_port *port, int pbn, int slots);
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
  2019-08-26 18:05 ` [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 18:36   ` Harry Wentland
  2019-08-26 18:05 ` [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions David Francis
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: 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

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 include/drm/drm_dp_mst_helper.h       | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 3e7b7553cf4d..9f3604355705 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -553,6 +553,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;
@@ -2183,6 +2184,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;
 		}
 	}
 
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 9116b2c95239..f113ae04fa88 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -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;
 };
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
  2019-08-26 18:05 ` [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes David Francis
  2019-08-26 18:05 ` [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 18:41   ` Harry Wentland
  2019-08-26 18:05 ` [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports David Francis
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: David Francis

Instead of having drm_dp_dpcd_read/write and
drm_dp_mst_dpcd_read/write as entry points into the
aux code, have drm_dp_dpcd_read/write handle both.

This means that DRM drivers can make MST DPCD read/writes.

v2: Fix spacing
v3: Dump dpcd access on MST read/writes

Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++----------
 drivers/gpu/drm/drm_dp_helper.c  | 30 ++++++++++++++++++++----------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c
index 0cfb386754c3..418cad4f649a 100644
--- a/drivers/gpu/drm/drm_dp_aux_dev.c
+++ b/drivers/gpu/drm/drm_dp_aux_dev.c
@@ -163,11 +163,7 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
 			break;
 		}
 
-		if (aux_dev->aux->is_remote)
-			res = drm_dp_mst_dpcd_read(aux_dev->aux, pos, buf,
-						   todo);
-		else
-			res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo);
+		res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo);
 
 		if (res <= 0)
 			break;
@@ -215,11 +211,7 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
 			break;
 		}
 
-		if (aux_dev->aux->is_remote)
-			res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf,
-						    todo);
-		else
-			res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo);
+		res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf, todo);
 
 		if (res <= 0)
 			break;
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index ffc68d305afe..2cc21eff4cf3 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -30,6 +30,7 @@
 #include <linux/seq_file.h>
 
 #include <drm/drm_dp_helper.h>
+#include <drm/drm_dp_mst_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_vblank.h>
 
@@ -251,7 +252,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
 
 /**
  * drm_dp_dpcd_read() - read a series of bytes from the DPCD
- * @aux: DisplayPort AUX channel
+ * @aux: DisplayPort AUX channel (SST or MST)
  * @offset: address of the (first) register to read
  * @buffer: buffer to store the register values
  * @size: number of bytes in @buffer
@@ -280,13 +281,18 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
 	 * We just have to do it before any DPCD access and hope that the
 	 * monitor doesn't power down exactly after the throw away read.
 	 */
-	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, buffer,
-				 1);
-	if (ret != 1)
-		goto out;
+	if (!aux->is_remote) {
+		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
+					 buffer, 1);
+		if (ret != 1)
+			goto out;
+	}
 
-	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
-				 size);
+	if (aux->is_remote)
+		ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size);
+	else
+		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
+					 buffer, size);
 
 out:
 	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
@@ -296,7 +302,7 @@ EXPORT_SYMBOL(drm_dp_dpcd_read);
 
 /**
  * drm_dp_dpcd_write() - write a series of bytes to the DPCD
- * @aux: DisplayPort AUX channel
+ * @aux: DisplayPort AUX channel (SST or MST)
  * @offset: address of the (first) register to write
  * @buffer: buffer containing the values to write
  * @size: number of bytes in @buffer
@@ -313,8 +319,12 @@ ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
 {
 	int ret;
 
-	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer,
-				 size);
+	if (aux->is_remote)
+		ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size);
+	else
+		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset,
+					 buffer, size);
+
 	drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret);
 	return ret;
 }
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
                   ` (2 preceding siblings ...)
  2019-08-26 18:05 ` [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 18:44   ` Harry Wentland
  2019-08-26 18:05 ` [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs David Francis
  2019-08-26 18:05 ` [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux David Francis
  5 siblings, 1 reply; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: David Francis

This field on drm_dp_mst_branch was never filled

It is initialized to zero when the port is kzallocced.
When a port is added to the list, increment num_ports,
and when a port is removed from the list, decrement num_ports.

v2: remember to decrement on port removal
v3: don't explicitly init to 0

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 9f3604355705..502923c24450 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1669,6 +1669,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);
 	}
 
@@ -1703,6 +1704,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
 			/* remove it from the port list */
 			mutex_lock(&mstb->mgr->lock);
 			list_del(&port->next);
+			mstb->num_ports--;
 			mutex_unlock(&mstb->mgr->lock);
 			/* drop port list reference */
 			drm_dp_mst_topology_put_port(port);
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
                   ` (3 preceding siblings ...)
  2019-08-26 18:05 ` [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 19:05   ` Harry Wentland
  2019-08-26 18:05 ` [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux David Francis
  5 siblings, 1 reply; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: David Francis

Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
support virtual DPCD registers, but do support DSC.
The DSC caps can be read from the physical aux,
like in SST DSC. These hubs have many different
DEVICE_IDs.  Add a new quirk to detect this case.

Cc: Lyude Paul <lyude@redhat.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 drivers/gpu/drm/drm_dp_helper.c | 2 ++
 include/drm/drm_dp_helper.h     | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 2cc21eff4cf3..fc39323e7d52 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
 	{ OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
 	/* CH7511 seems to leave SINK_COUNT zeroed */
 	{ OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
+	/* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
+	{ OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
 };
 
 #undef OUI
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 8364502f92cf..a1331b08705f 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
 	 * The driver should ignore SINK_COUNT during detection.
 	 */
 	DP_DPCD_QUIRK_NO_SINK_COUNT,
+	/**
+	 * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
+	 *
+	 * The device supports MST DSC despite not supporting Virtual DPCD.
+	 * The DSC caps can be read from the physical aux instead.
+	 */
+	DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
 };
 
 /**
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
  2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
                   ` (4 preceding siblings ...)
  2019-08-26 18:05 ` [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs David Francis
@ 2019-08-26 18:05 ` David Francis
  2019-08-26 19:16   ` Francis, David
  2019-08-26 20:51   ` Harry Wentland
  5 siblings, 2 replies; 18+ messages in thread
From: David Francis @ 2019-08-26 18:05 UTC (permalink / raw)
  To: dri-devel; +Cc: David Francis

Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED
register might have to be written on the leaf port's DPCD,
its parent's DPCD, or the MST manager's DPCD. This function
finds the correct aux for the job.

As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD
is a DP feature new in DP v1.4, which exposes certain DPCD
registers on virtual ports.

v2: Remember to unlock mutex on all paths

Cc: Lyude Paul <lyude@redhat.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 152 ++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |   2 +
 2 files changed, 154 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 502923c24450..1fee92bd51f7 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4150,3 +4150,155 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
 {
 	i2c_del_adapter(&aux->ddc);
 }
+
+/**
+ * drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device
+ * @port: The port to check
+ *
+ * A single physical MST hub object can be represented in the topology
+ * by multiple branches, with virtual ports between those branches.
+ *
+ * As of DP1.4, An MST hub with internal (virtual) ports must expose
+ * certain DPCD registers over those ports. See sections 2.6.1.1.1
+ * and 2.6.1.1.2 of Display Port specification v1.4 for details.
+ *
+ * May acquire mgr->lock
+ *
+ * Returns:
+ * true if the port is a virtual DP peer device, false otherwise
+ */
+static bool drm_dp_mst_is_virtual_dpcd(struct drm_dp_mst_port *port)
+{
+	struct drm_dp_mst_port *downstream_port;
+
+	if (!port)
+		return false;
+
+	/* Virtual DP Sink (Internal Display Panel) */
+	if (port->port_num >= 8 && port->dpcd_rev >= DP_DPCD_REV_14)
+		return true;
+
+	/* DP-to-HDMI Protocol Converter */
+	if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
+			!port->mcs &&
+			port->ldps &&
+			port->dpcd_rev >= DP_DPCD_REV_14)
+		return true;
+
+	/* DP-to-DP */
+	mutex_lock(&port->mgr->lock);
+	if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
+			port->mstb &&
+			port->dpcd_rev >= DP_DPCD_REV_14 &&
+			port->mstb->num_ports == 2) {
+		list_for_each_entry(downstream_port, &port->mstb->ports, next) {
+			if (downstream_port->pdt == DP_PEER_DEVICE_SST_SINK &&
+					!downstream_port->input) {
+				mutex_unlock(&port->mgr->lock);
+				return true;
+			}
+		}
+	}
+	mutex_unlock(&port->mgr->lock);
+
+	return false;
+}
+
+/**
+ * drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC
+ * @port: The port to check. A leaf of the MST tree with an attached display.
+ *
+ * Depending on the situation, DSC may be enabled via the endpoint aux,
+ * the immediately upstream aux, or the connector's physical aux.
+ *
+ * This is both the correct aux to read DSC_CAPABILITY and the
+ * correct aux to write DSC_ENABLED.
+ *
+ * This operation can be expensive (up to four aux reads), so
+ * the caller should cache the return.
+ *
+ * Returns:
+ * NULL if DSC cannot be enabled on this port, otherwise the aux device
+ */
+struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
+{
+	struct drm_dp_mst_port *immediate_upstream_port;
+	struct drm_dp_mst_port *fec_port;
+	struct drm_dp_desc *desc = NULL;
+
+	if (port && port->parent)
+		immediate_upstream_port = port->parent->port_parent;
+	else
+		immediate_upstream_port = NULL;
+
+	fec_port = immediate_upstream_port;
+	while (fec_port) {
+		/*
+		 * Each physical link (i.e. not a virtual port) between the
+		 * output and the primary device must support FEC
+		 */
+		if (!drm_dp_mst_is_virtual_dpcd(fec_port) &&
+				!fec_port->fec_capable)
+			return NULL;
+
+		fec_port = fec_port->parent->port_parent;
+	}
+
+	/* DP-to-DP peer device */
+	if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) {
+		u8 upstream_dsc;
+		u8 endpoint_dsc;
+		u8 endpoint_fec;
+
+		if (drm_dp_dpcd_read(&port->aux,
+				     DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0)
+			return NULL;
+		if (drm_dp_dpcd_read(&port->aux,
+				     DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0)
+			return NULL;
+		if (drm_dp_dpcd_read(&immediate_upstream_port->aux,
+				     DP_DSC_SUPPORT, &upstream_dsc, 1) < 0)
+			return NULL;
+
+		/* Enpoint decompression with DP-to-DP peer device */
+		if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED)
+				&& (endpoint_fec & DP_FEC_CAPABLE)
+				&& (upstream_dsc & 0x2) /* DSC passthrough */)
+			return &port->aux;
+
+		/* Virtual DPCD decompression with DP-to-DP peer device */
+		return &immediate_upstream_port->aux;
+	}
+
+	/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
+	if (drm_dp_mst_is_virtual_dpcd(port))
+		return &port->aux;
+
+	/*
+	 * Synaptics quirk
+	 * Applies to ports for which:
+	 * - Physical aux has Synaptics OUI
+	 * - DPv1.4 or higher
+	 * - Port is on primary branch device
+	 * - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG)
+	 */
+	if (!drm_dp_read_desc(port->mgr->aux, desc, true))
+		return false;
+
+	if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD &&
+			port->mgr->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) &&
+			port->parent == port->mgr->mst_primary) {
+		u8 downstreamport;
+
+		drm_dp_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT,
+				 &downstreamport, 1);
+
+		if ((downstreamport & DP_DWN_STRM_PORT_PRESENT) &&
+				((downstreamport & DP_DWN_STRM_PORT_TYPE_MASK)
+				!= DP_DWN_STRM_PORT_TYPE_ANALOG))
+			return port->mgr->aux;
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port);
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index f113ae04fa88..4cf738545dfb 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);
 void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port);
 void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port);
 
+struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port);
+
 extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs;
 
 /**
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes
  2019-08-26 18:05 ` [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes David Francis
@ 2019-08-26 18:36   ` Harry Wentland
  0 siblings, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 18:36 UTC (permalink / raw)
  To: Francis, David, dri-devel; +Cc: nouveau, intel-gfx, amd-gfx

On 2019-08-26 2:05 p.m., David Francis wrote:
> With DSC, bpp can be fractional in multiples of 1/16.
> 
> Change drm_dp_calc_pbn_mode to reflect this, adding a new
> parameter bool dsc. When this parameter is true, treat the
> bpp parameter as having units not of bits per pixel, but
> 1/16 of a bit per pixel
> 
> v2: Don't add separate function for this
> 
> Cc: amd-gfx@lists.freedesktop.org
> Cc: nouveau@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c    |  2 +-
>  drivers/gpu/drm/drm_dp_mst_topology.c            | 16 ++++++++++++----
>  drivers/gpu/drm/i915/display/intel_dp_mst.c      |  2 +-
>  drivers/gpu/drm/nouveau/dispnv50/disp.c          |  2 +-
>  drivers/gpu/drm/radeon/radeon_dp_mst.c           |  2 +-
>  include/drm/drm_dp_mst_helper.h                  |  3 +--
>  6 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index a0ed0154a9f0..abafb5221b44 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -235,7 +235,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
>  
>  		/* TODO need to know link rate */
>  
> -		pbn = drm_dp_calc_pbn_mode(clock, bpp);
> +		pbn = drm_dp_calc_pbn_mode(clock, bpp, false);
>  
>  		slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
>  		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 82add736e17d..3e7b7553cf4d 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3534,10 +3534,11 @@ EXPORT_SYMBOL(drm_dp_check_act_status);
>   * drm_dp_calc_pbn_mode() - Calculate the PBN for a mode.
>   * @clock: dot clock for the mode
>   * @bpp: bpp for the mode.
> + * @dsc: DSC mode. If true, bpp has units of 1/16 of a bit per pixel
>   *
>   * This uses the formula in the spec to calculate the PBN value for a mode.
>   */
> -int drm_dp_calc_pbn_mode(int clock, int bpp)
> +int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc)
>  {
>  	u64 kbps;
>  	s64 peak_kbps;
> @@ -3555,11 +3556,18 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)
>  	 * peak_kbps *= (1006/1000)
>  	 * peak_kbps *= (64/54)
>  	 * peak_kbps *= 8    convert to bytes
> +	 *
> +	 * If the bpp is in units of 1/16, further divide by 16. Put this
> +	 * factor in the numerator rather than the denominator to avoid
> +	 * integer overflow
>  	 */
>  
>  	numerator = 64 * 1006;
>  	denominator = 54 * 8 * 1000 * 1000;
>  
> +	if (dsc)
> +		numerator /= 16;
> +
>  	kbps *= numerator;
>  	peak_kbps = drm_fixp_from_fraction(kbps, denominator);
>  
> @@ -3570,19 +3578,19 @@ EXPORT_SYMBOL(drm_dp_calc_pbn_mode);
>  static int test_calc_pbn_mode(void)
>  {
>  	int ret;
> -	ret = drm_dp_calc_pbn_mode(154000, 30);
> +	ret = drm_dp_calc_pbn_mode(154000, 30, false);
>  	if (ret != 689) {
>  		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
>  				154000, 30, 689, ret);
>  		return -EINVAL;
>  	}
> -	ret = drm_dp_calc_pbn_mode(234000, 30);
> +	ret = drm_dp_calc_pbn_mode(234000, 30, false);
>  	if (ret != 1047) {
>  		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
>  				234000, 30, 1047, ret);
>  		return -EINVAL;
>  	}
> -	ret = drm_dp_calc_pbn_mode(297000, 24);
> +	ret = drm_dp_calc_pbn_mode(297000, 24, false);
>  	if (ret != 1063) {
>  		DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n",
>  				297000, 24, 1063, ret);
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index 2c5ac3dd647f..4f17f61f4453 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -61,7 +61,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
>  		crtc_state->pipe_bpp = bpp;
>  
>  		crtc_state->pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock,
> -						       crtc_state->pipe_bpp);
> +						       crtc_state->pipe_bpp, false);
>  
>  		slots = drm_dp_atomic_find_vcpi_slots(state, &intel_dp->mst_mgr,
>  						      port, crtc_state->pbn);
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index 5c36c75232e6..c68783c1f3fa 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -782,7 +782,7 @@ nv50_msto_atomic_check(struct drm_encoder *encoder,
>  			const int bpp = connector->display_info.bpc * 3;
>  			const int clock = crtc_state->adjusted_mode.clock;
>  
> -			asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp);
> +			asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp, false);
>  		}
>  
>  		slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr,
> diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
> index 2994f07fbad9..c997f88218f2 100644
> --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
> +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
> @@ -514,7 +514,7 @@ static bool radeon_mst_mode_fixup(struct drm_encoder *encoder,
>  
>  	mst_enc = radeon_encoder->enc_priv;
>  
> -	mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp);
> +	mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp, false);
>  
>  	mst_enc->primary->active_device = mst_enc->primary->devices & mst_enc->connector->devices;
>  	DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for encoder %d\n",
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index 2ba6253ea6d3..9116b2c95239 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -610,8 +610,7 @@ bool drm_dp_mst_port_has_audio(struct drm_dp_mst_topology_mgr *mgr,
>  struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
>  
>  
> -int drm_dp_calc_pbn_mode(int clock, int bpp);
> -
> +int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
>  
>  bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
>  			      struct drm_dp_mst_port *port, int pbn, int slots);
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports
  2019-08-26 18:05 ` [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports David Francis
@ 2019-08-26 18:36   ` Harry Wentland
  0 siblings, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 18:36 UTC (permalink / raw)
  To: Francis, David, dri-devel



On 2019-08-26 2:05 p.m., David Francis wrote:
> 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
> 
> Signed-off-by: David Francis <David.Francis@amd.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
>  include/drm/drm_dp_mst_helper.h       | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 3e7b7553cf4d..9f3604355705 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -553,6 +553,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;
> @@ -2183,6 +2184,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;
>  		}
>  	}
>  
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index 9116b2c95239..f113ae04fa88 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -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;
>  };
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions
  2019-08-26 18:05 ` [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions David Francis
@ 2019-08-26 18:41   ` Harry Wentland
  0 siblings, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 18:41 UTC (permalink / raw)
  To: Francis, David, dri-devel

On 2019-08-26 2:05 p.m., David Francis wrote:
> Instead of having drm_dp_dpcd_read/write and
> drm_dp_mst_dpcd_read/write as entry points into the
> aux code, have drm_dp_dpcd_read/write handle both.
> 
> This means that DRM drivers can make MST DPCD read/writes.
> 
> v2: Fix spacing
> v3: Dump dpcd access on MST read/writes
> 
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++----------
>  drivers/gpu/drm/drm_dp_helper.c  | 30 ++++++++++++++++++++----------
>  2 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c
> index 0cfb386754c3..418cad4f649a 100644
> --- a/drivers/gpu/drm/drm_dp_aux_dev.c
> +++ b/drivers/gpu/drm/drm_dp_aux_dev.c
> @@ -163,11 +163,7 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
>  			break;
>  		}
>  
> -		if (aux_dev->aux->is_remote)
> -			res = drm_dp_mst_dpcd_read(aux_dev->aux, pos, buf,
> -						   todo);
> -		else
> -			res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo);
> +		res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo);
>  
>  		if (res <= 0)
>  			break;
> @@ -215,11 +211,7 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  			break;
>  		}
>  
> -		if (aux_dev->aux->is_remote)
> -			res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf,
> -						    todo);
> -		else
> -			res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo);
> +		res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf, todo);
>  
>  		if (res <= 0)
>  			break;
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index ffc68d305afe..2cc21eff4cf3 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -30,6 +30,7 @@
>  #include <linux/seq_file.h>
>  
>  #include <drm/drm_dp_helper.h>
> +#include <drm/drm_dp_mst_helper.h>
>  #include <drm/drm_print.h>
>  #include <drm/drm_vblank.h>
>  
> @@ -251,7 +252,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
>  
>  /**
>   * drm_dp_dpcd_read() - read a series of bytes from the DPCD
> - * @aux: DisplayPort AUX channel
> + * @aux: DisplayPort AUX channel (SST or MST)
>   * @offset: address of the (first) register to read
>   * @buffer: buffer to store the register values
>   * @size: number of bytes in @buffer
> @@ -280,13 +281,18 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
>  	 * We just have to do it before any DPCD access and hope that the
>  	 * monitor doesn't power down exactly after the throw away read.
>  	 */
> -	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, buffer,
> -				 1);
> -	if (ret != 1)
> -		goto out;
> +	if (!aux->is_remote) {
> +		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
> +					 buffer, 1);
> +		if (ret != 1)
> +			goto out;
> +	}
>  
> -	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
> -				 size);
> +	if (aux->is_remote)
> +		ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size);
> +	else
> +		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
> +					 buffer, size);
>  
>  out:
>  	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
> @@ -296,7 +302,7 @@ EXPORT_SYMBOL(drm_dp_dpcd_read);
>  
>  /**
>   * drm_dp_dpcd_write() - write a series of bytes to the DPCD
> - * @aux: DisplayPort AUX channel
> + * @aux: DisplayPort AUX channel (SST or MST)
>   * @offset: address of the (first) register to write
>   * @buffer: buffer containing the values to write
>   * @size: number of bytes in @buffer
> @@ -313,8 +319,12 @@ ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
>  {
>  	int ret;
>  
> -	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer,
> -				 size);
> +	if (aux->is_remote)
> +		ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size);
> +	else
> +		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset,
> +					 buffer, size);
> +
>  	drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret);
>  	return ret;
>  }
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports
  2019-08-26 18:05 ` [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports David Francis
@ 2019-08-26 18:44   ` Harry Wentland
  0 siblings, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 18:44 UTC (permalink / raw)
  To: Francis, David, dri-devel

On 2019-08-26 2:05 p.m., David Francis wrote:
> This field on drm_dp_mst_branch was never filled
> 
> It is initialized to zero when the port is kzallocced.
> When a port is added to the list, increment num_ports,
> and when a port is removed from the list, decrement num_ports.
> 
> v2: remember to decrement on port removal
> v3: don't explicitly init to 0
> 
> Signed-off-by: David Francis <David.Francis@amd.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 9f3604355705..502923c24450 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1669,6 +1669,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);
>  	}
>  
> @@ -1703,6 +1704,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
>  			/* remove it from the port list */
>  			mutex_lock(&mstb->mgr->lock);
>  			list_del(&port->next);
> +			mstb->num_ports--;
>  			mutex_unlock(&mstb->mgr->lock);
>  			/* drop port list reference */
>  			drm_dp_mst_topology_put_port(port);
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
  2019-08-26 18:05 ` [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs David Francis
@ 2019-08-26 19:05   ` Harry Wentland
  2019-08-26 19:14     ` Francis, David
  0 siblings, 1 reply; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 19:05 UTC (permalink / raw)
  To: Francis, David, dri-devel

On 2019-08-26 2:05 p.m., David Francis wrote:
> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
> support virtual DPCD registers, but do support DSC.
> The DSC caps can be read from the physical aux,
> like in SST DSC. These hubs have many different
> DEVICE_IDs.  Add a new quirk to detect this case.
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>  include/drm/drm_dp_helper.h     | 7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 2cc21eff4cf3..fc39323e7d52 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>  	{ OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>  	/* CH7511 seems to leave SINK_COUNT zeroed */
>  	{ OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
> +	/* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
> +	{ OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },

This seems to be generic OUI for Synaptics [1]. Could this cause us to
cast the net too wide?

Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
Synaptics is fixing this in the future and won't require the quirk.

[1] https://aruljohn.com/mac/vendor/Synaptics

Harry

>  };
>  
>  #undef OUI
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 8364502f92cf..a1331b08705f 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>  	 * The driver should ignore SINK_COUNT during detection.
>  	 */
>  	DP_DPCD_QUIRK_NO_SINK_COUNT,
> +	/**
> +	 * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
> +	 *
> +	 * The device supports MST DSC despite not supporting Virtual DPCD.
> +	 * The DSC caps can be read from the physical aux instead.
> +	 */
> +	DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>  };
>  
>  /**
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
  2019-08-26 19:05   ` Harry Wentland
@ 2019-08-26 19:14     ` Francis, David
  2019-08-26 20:52       ` Harry Wentland
  2019-08-27  7:21       ` Jani Nikula
  0 siblings, 2 replies; 18+ messages in thread
From: Francis, David @ 2019-08-26 19:14 UTC (permalink / raw)
  To: Wentland, Harry, dri-devel

On 2019-08-26 2:05 p.m., David Francis wrote:
>> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
>> support virtual DPCD registers, but do support DSC.
>> The DSC caps can be read from the physical aux,
>> like in SST DSC. These hubs have many different
>> DEVICE_IDs.  Add a new quirk to detect this case.
>>
>> Cc: Lyude Paul <lyude@redhat.com>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Signed-off-by: David Francis <David.Francis@amd.com>
>> ---
>>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>>  include/drm/drm_dp_helper.h     | 7 +++++++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
>> index 2cc21eff4cf3..fc39323e7d52 100644
>> --- a/drivers/gpu/drm/drm_dp_helper.c
>> +++ b/drivers/gpu/drm/drm_dp_helper.c
>> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>>        { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>>        /* CH7511 seems to leave SINK_COUNT zeroed */
>>        { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
>> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
>> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
>
>This seems to be generic OUI for Synaptics [1]. Could this cause us to
>cast the net too wide?
>
>Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
>Synaptics is fixing this in the future and won't require the quirk.
>
>[1] https://aruljohn.com/mac/vendor/Synaptics
>
>
>Harry

It's not pretty, but
- Currently the net of "all Synaptics devices with rev>DP1.4" catches every device we care about and none we don't
- If a future Synaptics device supports virtual DPCD properly, we will check for that first and never resort to the workaround (see patch 6/6)
- We don't know any of the properties of any hypothetical future Synaptics hardware, so we can't create cases for them now

Also, received offline review from AMD MST DSC (Non-Linux) expert Wenjing Liu, giving me permission  o mark this patch
Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>

>
>>  };
>>
>>  #undef OUI
>> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>> index 8364502f92cf..a1331b08705f 100644
>> --- a/include/drm/drm_dp_helper.h
>> +++ b/include/drm/drm_dp_helper.h
>> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>>         * The driver should ignore SINK_COUNT during detection.
>>         */
>>        DP_DPCD_QUIRK_NO_SINK_COUNT,
>> +     /**
>> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
>> +      *
>> +      * The device supports MST DSC despite not supporting Virtual DPCD.
>> +      * The DSC caps can be read from the physical aux instead.
>> +      */
>> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>>  };
>>
>>  /**

________________________________________
From: Wentland, Harry <Harry.Wentland@amd.com>
Sent: August 26, 2019 3:05 PM
To: Francis, David; dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs

On 2019-08-26 2:05 p.m., David Francis wrote:
> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
> support virtual DPCD registers, but do support DSC.
> The DSC caps can be read from the physical aux,
> like in SST DSC. These hubs have many different
> DEVICE_IDs.  Add a new quirk to detect this case.
>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>  include/drm/drm_dp_helper.h     | 7 +++++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 2cc21eff4cf3..fc39323e7d52 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>       { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>       /* CH7511 seems to leave SINK_COUNT zeroed */
>       { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },

This seems to be generic OUI for Synaptics [1]. Could this cause us to
cast the net too wide?

Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
Synaptics is fixing this in the future and won't require the quirk.

[1] https://aruljohn.com/mac/vendor/Synaptics

Harry

>  };
>
>  #undef OUI
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 8364502f92cf..a1331b08705f 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>        * The driver should ignore SINK_COUNT during detection.
>        */
>       DP_DPCD_QUIRK_NO_SINK_COUNT,
> +     /**
> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
> +      *
> +      * The device supports MST DSC despite not supporting Virtual DPCD.
> +      * The DSC caps can be read from the physical aux instead.
> +      */
> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>  };
>
>  /**
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
  2019-08-26 18:05 ` [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux David Francis
@ 2019-08-26 19:16   ` Francis, David
  2019-08-26 20:27     ` Lyude Paul
  2019-08-26 20:51   ` Harry Wentland
  1 sibling, 1 reply; 18+ messages in thread
From: Francis, David @ 2019-08-26 19:16 UTC (permalink / raw)
  To: dri-devel

Received offline review from AMD MST DSC (Non-Linux) expert Wenjing Liu, giving me permission  to mark this patch
Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>

________________________________________
From: David Francis <David.Francis@amd.com>
Sent: August 26, 2019 2:05 PM
To: dri-devel@lists.freedesktop.org
Cc: Francis, David; Lyude Paul; Jani Nikula
Subject: [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux

Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED
register might have to be written on the leaf port's DPCD,
its parent's DPCD, or the MST manager's DPCD. This function
finds the correct aux for the job.

As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD
is a DP feature new in DP v1.4, which exposes certain DPCD
registers on virtual ports.

v2: Remember to unlock mutex on all paths

Cc: Lyude Paul <lyude@redhat.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: David Francis <David.Francis@amd.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 152 ++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |   2 +
 2 files changed, 154 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 502923c24450..1fee92bd51f7 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4150,3 +4150,155 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
 {
        i2c_del_adapter(&aux->ddc);
 }
+
+/**
+ * drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device
+ * @port: The port to check
+ *
+ * A single physical MST hub object can be represented in the topology
+ * by multiple branches, with virtual ports between those branches.
+ *
+ * As of DP1.4, An MST hub with internal (virtual) ports must expose
+ * certain DPCD registers over those ports. See sections 2.6.1.1.1
+ * and 2.6.1.1.2 of Display Port specification v1.4 for details.
+ *
+ * May acquire mgr->lock
+ *
+ * Returns:
+ * true if the port is a virtual DP peer device, false otherwise
+ */
+static bool drm_dp_mst_is_virtual_dpcd(struct drm_dp_mst_port *port)
+{
+       struct drm_dp_mst_port *downstream_port;
+
+       if (!port)
+               return false;
+
+       /* Virtual DP Sink (Internal Display Panel) */
+       if (port->port_num >= 8 && port->dpcd_rev >= DP_DPCD_REV_14)
+               return true;
+
+       /* DP-to-HDMI Protocol Converter */
+       if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
+                       !port->mcs &&
+                       port->ldps &&
+                       port->dpcd_rev >= DP_DPCD_REV_14)
+               return true;
+
+       /* DP-to-DP */
+       mutex_lock(&port->mgr->lock);
+       if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
+                       port->mstb &&
+                       port->dpcd_rev >= DP_DPCD_REV_14 &&
+                       port->mstb->num_ports == 2) {
+               list_for_each_entry(downstream_port, &port->mstb->ports, next) {
+                       if (downstream_port->pdt == DP_PEER_DEVICE_SST_SINK &&
+                                       !downstream_port->input) {
+                               mutex_unlock(&port->mgr->lock);
+                               return true;
+                       }
+               }
+       }
+       mutex_unlock(&port->mgr->lock);
+
+       return false;
+}
+
+/**
+ * drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC
+ * @port: The port to check. A leaf of the MST tree with an attached display.
+ *
+ * Depending on the situation, DSC may be enabled via the endpoint aux,
+ * the immediately upstream aux, or the connector's physical aux.
+ *
+ * This is both the correct aux to read DSC_CAPABILITY and the
+ * correct aux to write DSC_ENABLED.
+ *
+ * This operation can be expensive (up to four aux reads), so
+ * the caller should cache the return.
+ *
+ * Returns:
+ * NULL if DSC cannot be enabled on this port, otherwise the aux device
+ */
+struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
+{
+       struct drm_dp_mst_port *immediate_upstream_port;
+       struct drm_dp_mst_port *fec_port;
+       struct drm_dp_desc *desc = NULL;
+
+       if (port && port->parent)
+               immediate_upstream_port = port->parent->port_parent;
+       else
+               immediate_upstream_port = NULL;
+
+       fec_port = immediate_upstream_port;
+       while (fec_port) {
+               /*
+                * Each physical link (i.e. not a virtual port) between the
+                * output and the primary device must support FEC
+                */
+               if (!drm_dp_mst_is_virtual_dpcd(fec_port) &&
+                               !fec_port->fec_capable)
+                       return NULL;
+
+               fec_port = fec_port->parent->port_parent;
+       }
+
+       /* DP-to-DP peer device */
+       if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) {
+               u8 upstream_dsc;
+               u8 endpoint_dsc;
+               u8 endpoint_fec;
+
+               if (drm_dp_dpcd_read(&port->aux,
+                                    DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0)
+                       return NULL;
+               if (drm_dp_dpcd_read(&port->aux,
+                                    DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0)
+                       return NULL;
+               if (drm_dp_dpcd_read(&immediate_upstream_port->aux,
+                                    DP_DSC_SUPPORT, &upstream_dsc, 1) < 0)
+                       return NULL;
+
+               /* Enpoint decompression with DP-to-DP peer device */
+               if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED)
+                               && (endpoint_fec & DP_FEC_CAPABLE)
+                               && (upstream_dsc & 0x2) /* DSC passthrough */)
+                       return &port->aux;
+
+               /* Virtual DPCD decompression with DP-to-DP peer device */
+               return &immediate_upstream_port->aux;
+       }
+
+       /* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
+       if (drm_dp_mst_is_virtual_dpcd(port))
+               return &port->aux;
+
+       /*
+        * Synaptics quirk
+        * Applies to ports for which:
+        * - Physical aux has Synaptics OUI
+        * - DPv1.4 or higher
+        * - Port is on primary branch device
+        * - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG)
+        */
+       if (!drm_dp_read_desc(port->mgr->aux, desc, true))
+               return false;
+
+       if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD &&
+                       port->mgr->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) &&
+                       port->parent == port->mgr->mst_primary) {
+               u8 downstreamport;
+
+               drm_dp_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT,
+                                &downstreamport, 1);
+
+               if ((downstreamport & DP_DWN_STRM_PORT_PRESENT) &&
+                               ((downstreamport & DP_DWN_STRM_PORT_TYPE_MASK)
+                               != DP_DWN_STRM_PORT_TYPE_ANALOG))
+                       return port->mgr->aux;
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port);
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index f113ae04fa88..4cf738545dfb 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);
 void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port);
 void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port);

+struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port);
+
 extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs;

 /**
--
2.17.1

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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
  2019-08-26 19:16   ` Francis, David
@ 2019-08-26 20:27     ` Lyude Paul
  0 siblings, 0 replies; 18+ messages in thread
From: Lyude Paul @ 2019-08-26 20:27 UTC (permalink / raw)
  To: Francis, David, dri-devel

Please fix the indenting on this. I've mentioned this already in my previous
reviews.

On Mon, 2019-08-26 at 19:16 +0000, Francis, David wrote:
> Received offline review from AMD MST DSC (Non-Linux) expert Wenjing Liu,
> giving me permission  to mark this patch
> Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>
> 
> ________________________________________
> From: David Francis <David.Francis@amd.com>
> Sent: August 26, 2019 2:05 PM
> To: dri-devel@lists.freedesktop.org
> Cc: Francis, David; Lyude Paul; Jani Nikula
> Subject: [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD
> aux
> 
> Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED
> register might have to be written on the leaf port's DPCD,
> its parent's DPCD, or the MST manager's DPCD. This function
> finds the correct aux for the job.
> 
> As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD
> is a DP feature new in DP v1.4, which exposes certain DPCD
> registers on virtual ports.
> 
> v2: Remember to unlock mutex on all paths
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 152 ++++++++++++++++++++++++++
>  include/drm/drm_dp_mst_helper.h       |   2 +
>  2 files changed, 154 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 502923c24450..1fee92bd51f7 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4150,3 +4150,155 @@ static void drm_dp_mst_unregister_i2c_bus(struct
> drm_dp_aux *aux)
>  {
>         i2c_del_adapter(&aux->ddc);
>  }
> +
> +/**
> + * drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer
> Device
> + * @port: The port to check
> + *
> + * A single physical MST hub object can be represented in the topology
> + * by multiple branches, with virtual ports between those branches.
> + *
> + * As of DP1.4, An MST hub with internal (virtual) ports must expose
> + * certain DPCD registers over those ports. See sections 2.6.1.1.1
> + * and 2.6.1.1.2 of Display Port specification v1.4 for details.
> + *
> + * May acquire mgr->lock
> + *
> + * Returns:
> + * true if the port is a virtual DP peer device, false otherwise
> + */
> +static bool drm_dp_mst_is_virtual_dpcd(struct drm_dp_mst_port *port)
> +{
> +       struct drm_dp_mst_port *downstream_port;
> +
> +       if (!port)
> +               return false;
> +
> +       /* Virtual DP Sink (Internal Display Panel) */
> +       if (port->port_num >= 8 && port->dpcd_rev >= DP_DPCD_REV_14)
> +               return true;
> +
> +       /* DP-to-HDMI Protocol Converter */
> +       if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
> +                       !port->mcs &&
> +                       port->ldps &&
> +                       port->dpcd_rev >= DP_DPCD_REV_14)
> +               return true;
> +
> +       /* DP-to-DP */
> +       mutex_lock(&port->mgr->lock);
> +       if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
> +                       port->mstb &&
> +                       port->dpcd_rev >= DP_DPCD_REV_14 &&
> +                       port->mstb->num_ports == 2) {
> +               list_for_each_entry(downstream_port, &port->mstb->ports,
> next) {
> +                       if (downstream_port->pdt == DP_PEER_DEVICE_SST_SINK
> &&
> +                                       !downstream_port->input) {
> +                               mutex_unlock(&port->mgr->lock);
> +                               return true;
> +                       }
> +               }
> +       }
> +       mutex_unlock(&port->mgr->lock);
> +
> +       return false;
> +}
> +
> +/**
> + * drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC
> + * @port: The port to check. A leaf of the MST tree with an attached
> display.
> + *
> + * Depending on the situation, DSC may be enabled via the endpoint aux,
> + * the immediately upstream aux, or the connector's physical aux.
> + *
> + * This is both the correct aux to read DSC_CAPABILITY and the
> + * correct aux to write DSC_ENABLED.
> + *
> + * This operation can be expensive (up to four aux reads), so
> + * the caller should cache the return.
> + *
> + * Returns:
> + * NULL if DSC cannot be enabled on this port, otherwise the aux device
> + */
> +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port
> *port)
> +{
> +       struct drm_dp_mst_port *immediate_upstream_port;
> +       struct drm_dp_mst_port *fec_port;
> +       struct drm_dp_desc *desc = NULL;
> +
> +       if (port && port->parent)
> +               immediate_upstream_port = port->parent->port_parent;
> +       else
> +               immediate_upstream_port = NULL;
> +
> +       fec_port = immediate_upstream_port;
> +       while (fec_port) {
> +               /*
> +                * Each physical link (i.e. not a virtual port) between the
> +                * output and the primary device must support FEC
> +                */
> +               if (!drm_dp_mst_is_virtual_dpcd(fec_port) &&
> +                               !fec_port->fec_capable)
> +                       return NULL;
> +
> +               fec_port = fec_port->parent->port_parent;
> +       }
> +
> +       /* DP-to-DP peer device */
> +       if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) {
> +               u8 upstream_dsc;
> +               u8 endpoint_dsc;
> +               u8 endpoint_fec;
> +
> +               if (drm_dp_dpcd_read(&port->aux,
> +                                    DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0)
> +                       return NULL;
> +               if (drm_dp_dpcd_read(&port->aux,
> +                                    DP_FEC_CAPABILITY, &endpoint_fec, 1) <
> 0)
> +                       return NULL;
> +               if (drm_dp_dpcd_read(&immediate_upstream_port->aux,
> +                                    DP_DSC_SUPPORT, &upstream_dsc, 1) < 0)
> +                       return NULL;
> +
> +               /* Enpoint decompression with DP-to-DP peer device */
> +               if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED)
> +                               && (endpoint_fec & DP_FEC_CAPABLE)
> +                               && (upstream_dsc & 0x2) /* DSC passthrough
> */)
> +                       return &port->aux;
> +
> +               /* Virtual DPCD decompression with DP-to-DP peer device */
> +               return &immediate_upstream_port->aux;
> +       }
> +
> +       /* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
> +       if (drm_dp_mst_is_virtual_dpcd(port))
> +               return &port->aux;
> +
> +       /*
> +        * Synaptics quirk
> +        * Applies to ports for which:
> +        * - Physical aux has Synaptics OUI
> +        * - DPv1.4 or higher
> +        * - Port is on primary branch device
> +        * - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG)
> +        */
> +       if (!drm_dp_read_desc(port->mgr->aux, desc, true))
> +               return false;
> +
> +       if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD &&
> +                       port->mgr->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) &&
> +                       port->parent == port->mgr->mst_primary) {
> +               u8 downstreamport;
> +
> +               drm_dp_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT,
> +                                &downstreamport, 1);
> +
> +               if ((downstreamport & DP_DWN_STRM_PORT_PRESENT) &&
> +                               ((downstreamport &
> DP_DWN_STRM_PORT_TYPE_MASK)
> +                               != DP_DWN_STRM_PORT_TYPE_ANALOG))
> +                       return port->mgr->aux;
> +       }
> +
> +       return NULL;
> +}
> +EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port);
> diff --git a/include/drm/drm_dp_mst_helper.h
> b/include/drm/drm_dp_mst_helper.h
> index f113ae04fa88..4cf738545dfb 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct
> drm_atomic_state *state);
>  void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port);
>  void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port);
> 
> +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port
> *port);
> +
>  extern const struct drm_private_state_funcs
> drm_dp_mst_topology_state_funcs;
> 
>  /**
> --
> 2.17.1
> 
-- 
Cheers,
	Lyude Paul

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
  2019-08-26 18:05 ` [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux David Francis
  2019-08-26 19:16   ` Francis, David
@ 2019-08-26 20:51   ` Harry Wentland
  1 sibling, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 20:51 UTC (permalink / raw)
  To: Francis, David, dri-devel

On 2019-08-26 2:05 p.m., David Francis wrote:
> Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED
> register might have to be written on the leaf port's DPCD,
> its parent's DPCD, or the MST manager's DPCD. This function
> finds the correct aux for the job.
> 
> As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD
> is a DP feature new in DP v1.4, which exposes certain DPCD
> registers on virtual ports.
> 
> v2: Remember to unlock mutex on all paths
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 152 ++++++++++++++++++++++++++
>  include/drm/drm_dp_mst_helper.h       |   2 +
>  2 files changed, 154 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 502923c24450..1fee92bd51f7 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4150,3 +4150,155 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux)
>  {
>  	i2c_del_adapter(&aux->ddc);
>  }
> +
> +/**
> + * drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device
> + * @port: The port to check
> + *
> + * A single physical MST hub object can be represented in the topology
> + * by multiple branches, with virtual ports between those branches.
> + *
> + * As of DP1.4, An MST hub with internal (virtual) ports must expose
> + * certain DPCD registers over those ports. See sections 2.6.1.1.1
> + * and 2.6.1.1.2 of Display Port specification v1.4 for details.
> + *

I've briefly perused these sections and they seem quite vague. What we
have here is probably a reasonable implementation, though.

Might be worthwhile to mention that the spec is not very clear on this
and that this is the best interpretation we have.

> + * May acquire mgr->lock
> + *
> + * Returns:
> + * true if the port is a virtual DP peer device, false otherwise
> + */
> +static bool drm_dp_mst_is_virtual_dpcd(struct drm_dp_mst_port *port)
> +{
> +	struct drm_dp_mst_port *downstream_port;
> +
> +	if (!port)
> +		return false;
> +

Can we early return with false if dpcd_rev < DP_DPCD_REV_14 rather than
check this in each if statement below?

> +	/* Virtual DP Sink (Internal Display Panel) */
> +	if (port->port_num >= 8 && port->dpcd_rev >= DP_DPCD_REV_14)
> +		return true;
> +
> +	/* DP-to-HDMI Protocol Converter */
> +	if (port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV &&
> +			!port->mcs &&
> +			port->ldps &&
> +			port->dpcd_rev >= DP_DPCD_REV_14)
> +		return true;
> +
> +	/* DP-to-DP */
> +	mutex_lock(&port->mgr->lock);
> +	if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
> +			port->mstb &&
> +			port->dpcd_rev >= DP_DPCD_REV_14 &&
> +			port->mstb->num_ports == 2) {

Is 'num_ports == 2' required? Maybe I don't follow this bit...

> +		list_for_each_entry(downstream_port, &port->mstb->ports, next) {
> +			if (downstream_port->pdt == DP_PEER_DEVICE_SST_SINK &&
> +					!downstream_port->input) {
> +				mutex_unlock(&port->mgr->lock);
> +				return true;
> +			}
> +		}
> +	}
> +	mutex_unlock(&port->mgr->lock);
> +
> +	return false;
> +}
> +
> +/**
> + * drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC
> + * @port: The port to check. A leaf of the MST tree with an attached display.
> + *
> + * Depending on the situation, DSC may be enabled via the endpoint aux,
> + * the immediately upstream aux, or the connector's physical aux.
> + *
> + * This is both the correct aux to read DSC_CAPABILITY and the
> + * correct aux to write DSC_ENABLED.
> + *
> + * This operation can be expensive (up to four aux reads), so
> + * the caller should cache the return.
> + *
> + * Returns:
> + * NULL if DSC cannot be enabled on this port, otherwise the aux device
> + */
> +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
> +{
> +	struct drm_dp_mst_port *immediate_upstream_port;
> +	struct drm_dp_mst_port *fec_port;
> +	struct drm_dp_desc *desc = NULL;
> +

Might be good to early return if !port to avoid proceeding through the
entire function if this is called without a port.

> +	if (port && port->parent)
> +		immediate_upstream_port = port->parent->port_parent;
> +	else
> +		immediate_upstream_port = NULL;
> +
> +	fec_port = immediate_upstream_port;
> +	while (fec_port) {
> +		/*
> +		 * Each physical link (i.e. not a virtual port) between the
> +		 * output and the primary device must support FEC
> +		 */
> +		if (!drm_dp_mst_is_virtual_dpcd(fec_port) &&
> +				!fec_port->fec_capable)
> +			return NULL;
> +
> +		fec_port = fec_port->parent->port_parent;
> +	}
> +
> +	/* DP-to-DP peer device */
> +	if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) {
> +		u8 upstream_dsc;
> +		u8 endpoint_dsc;
> +		u8 endpoint_fec;
> +
> +		if (drm_dp_dpcd_read(&port->aux,
> +				     DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0)
> +			return NULL;
> +		if (drm_dp_dpcd_read(&port->aux,
> +				     DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0)
> +			return NULL;
> +		if (drm_dp_dpcd_read(&immediate_upstream_port->aux,
> +				     DP_DSC_SUPPORT, &upstream_dsc, 1) < 0)
> +			return NULL;
> +
> +		/* Enpoint decompression with DP-to-DP peer device */
> +		if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED)
> +				&& (endpoint_fec & DP_FEC_CAPABLE)
> +				&& (upstream_dsc & 0x2) /* DSC passthrough */)
> +			return &port->aux;
> +
> +		/* Virtual DPCD decompression with DP-to-DP peer device */
> +		return &immediate_upstream_port->aux;
> +	}
> +
> +	/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */
> +	if (drm_dp_mst_is_virtual_dpcd(port))
> +		return &port->aux;
> +
> +	/*
> +	 * Synaptics quirk
> +	 * Applies to ports for which:
> +	 * - Physical aux has Synaptics OUI
> +	 * - DPv1.4 or higher
> +	 * - Port is on primary branch device
> +	 * - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG)
> +	 */
> +	if (!drm_dp_read_desc(port->mgr->aux, desc, true))
> +		return false;
> +
> +	if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD &&
> +			port->mgr->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) &&

Did you misplace that closing paranthesis? Shouldn't it be on the
previous line before the && ?

> +			port->parent == port->mgr->mst_primary) {

Use tabs & spaces to align with first element of if statement. Proper
indentation (with the function argument or elements of the if statement)
would make it obvious whether the above paranthesis has been replaced or
not.

Harry

> +		u8 downstreamport;
> +
> +		drm_dp_dpcd_read(&port->aux, DP_DOWNSTREAMPORT_PRESENT,
> +				 &downstreamport, 1);
> +
> +		if ((downstreamport & DP_DWN_STRM_PORT_PRESENT) &&
> +				((downstreamport & DP_DWN_STRM_PORT_TYPE_MASK)
> +				!= DP_DWN_STRM_PORT_TYPE_ANALOG))
> +			return port->mgr->aux;
> +	}
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port);
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index f113ae04fa88..4cf738545dfb 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);
>  void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port);
>  void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port);
>  
> +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port);
> +
>  extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs;
>  
>  /**
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
  2019-08-26 19:14     ` Francis, David
@ 2019-08-26 20:52       ` Harry Wentland
  2019-08-27  7:21       ` Jani Nikula
  1 sibling, 0 replies; 18+ messages in thread
From: Harry Wentland @ 2019-08-26 20:52 UTC (permalink / raw)
  To: Francis, David, Wentland, Harry, dri-devel

On 2019-08-26 3:14 p.m., Francis, David wrote:
> On 2019-08-26 2:05 p.m., David Francis wrote:
>>> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
>>> support virtual DPCD registers, but do support DSC.
>>> The DSC caps can be read from the physical aux,
>>> like in SST DSC. These hubs have many different
>>> DEVICE_IDs.  Add a new quirk to detect this case.
>>>
>>> Cc: Lyude Paul <lyude@redhat.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Signed-off-by: David Francis <David.Francis@amd.com>
>>> ---
>>>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>>>  include/drm/drm_dp_helper.h     | 7 +++++++
>>>  2 files changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
>>> index 2cc21eff4cf3..fc39323e7d52 100644
>>> --- a/drivers/gpu/drm/drm_dp_helper.c
>>> +++ b/drivers/gpu/drm/drm_dp_helper.c
>>> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>>>        { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>>>        /* CH7511 seems to leave SINK_COUNT zeroed */
>>>        { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
>>> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
>>> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
>>
>> This seems to be generic OUI for Synaptics [1]. Could this cause us to
>> cast the net too wide?
>>
>> Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
>> Synaptics is fixing this in the future and won't require the quirk.
>>
>> [1] https://aruljohn.com/mac/vendor/Synaptics
>>
>>
>> Harry
> 
> It's not pretty, but
> - Currently the net of "all Synaptics devices with rev>DP1.4" catches every device we care about and none we don't
> - If a future Synaptics device supports virtual DPCD properly, we will check for that first and never resort to the workaround (see patch 6/6)
> - We don't know any of the properties of any hypothetical future Synaptics hardware, so we can't create cases for them now
> 

That's fair enough. Thanks for the explanation.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> Also, received offline review from AMD MST DSC (Non-Linux) expert Wenjing Liu, giving me permission  o mark this patch
> Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>
> 
>>
>>>  };
>>>
>>>  #undef OUI
>>> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>>> index 8364502f92cf..a1331b08705f 100644
>>> --- a/include/drm/drm_dp_helper.h
>>> +++ b/include/drm/drm_dp_helper.h
>>> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>>>         * The driver should ignore SINK_COUNT during detection.
>>>         */
>>>        DP_DPCD_QUIRK_NO_SINK_COUNT,
>>> +     /**
>>> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
>>> +      *
>>> +      * The device supports MST DSC despite not supporting Virtual DPCD.
>>> +      * The DSC caps can be read from the physical aux instead.
>>> +      */
>>> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>>>  };
>>>
>>>  /**
> 
> ________________________________________
> From: Wentland, Harry <Harry.Wentland@amd.com>
> Sent: August 26, 2019 3:05 PM
> To: Francis, David; dri-devel@lists.freedesktop.org
> Subject: Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
> 
> On 2019-08-26 2:05 p.m., David Francis wrote:
>> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
>> support virtual DPCD registers, but do support DSC.
>> The DSC caps can be read from the physical aux,
>> like in SST DSC. These hubs have many different
>> DEVICE_IDs.  Add a new quirk to detect this case.
>>
>> Cc: Lyude Paul <lyude@redhat.com>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Signed-off-by: David Francis <David.Francis@amd.com>
>> ---
>>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>>  include/drm/drm_dp_helper.h     | 7 +++++++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
>> index 2cc21eff4cf3..fc39323e7d52 100644
>> --- a/drivers/gpu/drm/drm_dp_helper.c
>> +++ b/drivers/gpu/drm/drm_dp_helper.c
>> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>>       { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>>       /* CH7511 seems to leave SINK_COUNT zeroed */
>>       { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
>> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
>> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
> 
> This seems to be generic OUI for Synaptics [1]. Could this cause us to
> cast the net too wide?
> 
> Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
> Synaptics is fixing this in the future and won't require the quirk.
> 
> [1] https://aruljohn.com/mac/vendor/Synaptics
> 
> Harry
> 
>>  };
>>
>>  #undef OUI
>> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>> index 8364502f92cf..a1331b08705f 100644
>> --- a/include/drm/drm_dp_helper.h
>> +++ b/include/drm/drm_dp_helper.h
>> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>>        * The driver should ignore SINK_COUNT during detection.
>>        */
>>       DP_DPCD_QUIRK_NO_SINK_COUNT,
>> +     /**
>> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
>> +      *
>> +      * The device supports MST DSC despite not supporting Virtual DPCD.
>> +      * The DSC caps can be read from the physical aux instead.
>> +      */
>> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>>  };
>>
>>  /**
>>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
  2019-08-26 19:14     ` Francis, David
  2019-08-26 20:52       ` Harry Wentland
@ 2019-08-27  7:21       ` Jani Nikula
  1 sibling, 0 replies; 18+ messages in thread
From: Jani Nikula @ 2019-08-27  7:21 UTC (permalink / raw)
  To: Francis, David, Wentland, Harry, dri-devel

On Mon, 26 Aug 2019, "Francis, David" <David.Francis@amd.com> wrote:
> On 2019-08-26 2:05 p.m., David Francis wrote:
>>> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
>>> support virtual DPCD registers, but do support DSC.
>>> The DSC caps can be read from the physical aux,
>>> like in SST DSC. These hubs have many different
>>> DEVICE_IDs.  Add a new quirk to detect this case.
>>>
>>> Cc: Lyude Paul <lyude@redhat.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Signed-off-by: David Francis <David.Francis@amd.com>
>>> ---
>>>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>>>  include/drm/drm_dp_helper.h     | 7 +++++++
>>>  2 files changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
>>> index 2cc21eff4cf3..fc39323e7d52 100644
>>> --- a/drivers/gpu/drm/drm_dp_helper.c
>>> +++ b/drivers/gpu/drm/drm_dp_helper.c
>>> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>>>        { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>>>        /* CH7511 seems to leave SINK_COUNT zeroed */
>>>        { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
>>> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
>>> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
>>
>>This seems to be generic OUI for Synaptics [1]. Could this cause us to
>>cast the net too wide?
>>
>>Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
>>Synaptics is fixing this in the future and won't require the quirk.
>>
>>[1] https://aruljohn.com/mac/vendor/Synaptics
>>
>>
>>Harry
>
> It's not pretty, but
> - Currently the net of "all Synaptics devices with rev>DP1.4" catches every device we care about and none we don't
> - If a future Synaptics device supports virtual DPCD properly, we will check for that first and never resort to the workaround (see patch 6/6)
> - We don't know any of the properties of any hypothetical future Synaptics hardware, so we can't create cases for them now

One consideration is that if this causes certain behaviour in future
hardware, and, by coincidence, that happens to be desired behaviour, and
objectively fixing it (removing the quirk) causes a regression in that
desired behaviour, it's a regression.

I'm not sure what the right approach here is, but you really do need to
be aware of the kind of corners you might paint yourself into.

BR,
Jani.


>
> Also, received offline review from AMD MST DSC (Non-Linux) expert Wenjing Liu, giving me permission  o mark this patch
> Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>
>
>>
>>>  };
>>>
>>>  #undef OUI
>>> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>>> index 8364502f92cf..a1331b08705f 100644
>>> --- a/include/drm/drm_dp_helper.h
>>> +++ b/include/drm/drm_dp_helper.h
>>> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>>>         * The driver should ignore SINK_COUNT during detection.
>>>         */
>>>        DP_DPCD_QUIRK_NO_SINK_COUNT,
>>> +     /**
>>> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
>>> +      *
>>> +      * The device supports MST DSC despite not supporting Virtual DPCD.
>>> +      * The DSC caps can be read from the physical aux instead.
>>> +      */
>>> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>>>  };
>>>
>>>  /**
>
> ________________________________________
> From: Wentland, Harry <Harry.Wentland@amd.com>
> Sent: August 26, 2019 3:05 PM
> To: Francis, David; dri-devel@lists.freedesktop.org
> Subject: Re: [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs
>
> On 2019-08-26 2:05 p.m., David Francis wrote:
>> Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not
>> support virtual DPCD registers, but do support DSC.
>> The DSC caps can be read from the physical aux,
>> like in SST DSC. These hubs have many different
>> DEVICE_IDs.  Add a new quirk to detect this case.
>>
>> Cc: Lyude Paul <lyude@redhat.com>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Signed-off-by: David Francis <David.Francis@amd.com>
>> ---
>>  drivers/gpu/drm/drm_dp_helper.c | 2 ++
>>  include/drm/drm_dp_helper.h     | 7 +++++++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
>> index 2cc21eff4cf3..fc39323e7d52 100644
>> --- a/drivers/gpu/drm/drm_dp_helper.c
>> +++ b/drivers/gpu/drm/drm_dp_helper.c
>> @@ -1270,6 +1270,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
>>       { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) },
>>       /* CH7511 seems to leave SINK_COUNT zeroed */
>>       { OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
>> +     /* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
>> +     { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
>
> This seems to be generic OUI for Synaptics [1]. Could this cause us to
> cast the net too wide?
>
> Even if we check that it's DP_DPCD_REV >= 1.4 there's a good chance
> Synaptics is fixing this in the future and won't require the quirk.
>
> [1] https://aruljohn.com/mac/vendor/Synaptics
>
> Harry
>
>>  };
>>
>>  #undef OUI
>> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>> index 8364502f92cf..a1331b08705f 100644
>> --- a/include/drm/drm_dp_helper.h
>> +++ b/include/drm/drm_dp_helper.h
>> @@ -1434,6 +1434,13 @@ enum drm_dp_quirk {
>>        * The driver should ignore SINK_COUNT during detection.
>>        */
>>       DP_DPCD_QUIRK_NO_SINK_COUNT,
>> +     /**
>> +      * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
>> +      *
>> +      * The device supports MST DSC despite not supporting Virtual DPCD.
>> +      * The DSC caps can be read from the physical aux instead.
>> +      */
>> +     DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
>>  };
>>
>>  /**
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-08-27  7:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 18:05 [PATCH v8 0/6] DSC MST support in DRM David Francis
2019-08-26 18:05 ` [PATCH v8 1/6] drm/dp_mst: Add PBN calculation for DSC modes David Francis
2019-08-26 18:36   ` Harry Wentland
2019-08-26 18:05 ` [PATCH v8 2/6] drm/dp_mst: Parse FEC capability on MST ports David Francis
2019-08-26 18:36   ` Harry Wentland
2019-08-26 18:05 ` [PATCH v8 3/6] drm/dp_mst: Add MST support to DP DPCD R/W functions David Francis
2019-08-26 18:41   ` Harry Wentland
2019-08-26 18:05 ` [PATCH v8 4/6] drm/dp_mst: Fill branch->num_ports David Francis
2019-08-26 18:44   ` Harry Wentland
2019-08-26 18:05 ` [PATCH v8 5/6] drm/dp_mst: Add new quirk for Synaptics MST hubs David Francis
2019-08-26 19:05   ` Harry Wentland
2019-08-26 19:14     ` Francis, David
2019-08-26 20:52       ` Harry Wentland
2019-08-27  7:21       ` Jani Nikula
2019-08-26 18:05 ` [PATCH v8 6/6] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux David Francis
2019-08-26 19:16   ` Francis, David
2019-08-26 20:27     ` Lyude Paul
2019-08-26 20:51   ` Harry Wentland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.