Skip to contentSkip to conversation

drm/nouveau/disp: fix HDMI on gt215+

PATCH New Karol Herbst 1 participant 3 messages Jun 28, 2023

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

PATCH 1/3 drm/nouveau/disp: fix HDMI on gt215+

Cc Ben Skeggs <[email protected]>
Cc Lyude Paul <[email protected]>
Fixes f530bc60a30b ("drm/nouveau/disp: move HDMI config into acquire + infoframe methods")
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c +1 -1
index a2c7c6f83dcd..506ffbe7b842 100644
@@ -125,7 +125,7 @@ gt215_sor_hdmi_infoframe_avi(struct nvkm_ior *ior, int head, void *data, u32 siz
 	pack_hdmi_infoframe(&avi, data, size);
 
 	nvkm_mask(device, 0x61c520 + soff, 0x00000001, 0x00000000);
-	if (size)
+	if (!size)
 		return;
 
 	nvkm_wr32(device, 0x61c528 + soff, avi.header);
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/3 drm/nouveau/disp: drop unused argument in nv50_dp_mode_valid

---
 drivers/gpu/drm/nouveau/dispnv50/disp.c     | 2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_dp.c        | 3 +--
 drivers/gpu/drm/nouveau/nouveau_encoder.h   | 3 +--
 4 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -1
index 1637e08b548c..6221eaaad1b7 100644
@@ -1127,7 +1127,7 @@ nv50_mstc_mode_valid(struct drm_connector *connector,
 	 * MSTB's max possible PBN
 	 */
 
-	return nv50_dp_mode_valid(connector, outp, mode, NULL);
+	return nv50_dp_mode_valid(outp, mode, NULL);
 }
 
 static int
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
index f75c6f09dd2a..22c42a5e184d 100644
@@ -1079,7 +1079,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
 	case DCB_OUTPUT_TV:
 		return get_slave_funcs(encoder)->mode_valid(encoder, mode);
 	case DCB_OUTPUT_DP:
-		return nv50_dp_mode_valid(connector, nv_encoder, mode, NULL);
+		return nv50_dp_mode_valid(nv_encoder, mode, NULL);
 	default:
 		BUG();
 		return MODE_BAD;
drivers/gpu/drm/nouveau/nouveau_dp.c +1 -2
index d49b4875fc3c..6a4980b2d4d4 100644
@@ -267,8 +267,7 @@ nouveau_dp_irq(struct work_struct *work)
  *   yet)
  */
 enum drm_mode_status
-nv50_dp_mode_valid(struct drm_connector *connector,
-		   struct nouveau_encoder *outp,
+nv50_dp_mode_valid(struct nouveau_encoder *outp,
 		   const struct drm_display_mode *mode,
 		   unsigned *out_clock)
 {
drivers/gpu/drm/nouveau/nouveau_encoder.h +1 -2
index 70c1ad6c4d9d..bcba1a14cfab 100644
@@ -143,8 +143,7 @@ enum nouveau_dp_status {
 int nouveau_dp_detect(struct nouveau_connector *, struct nouveau_encoder *);
 bool nouveau_dp_link_check(struct nouveau_connector *);
 void nouveau_dp_irq(struct work_struct *);
-enum drm_mode_status nv50_dp_mode_valid(struct drm_connector *,
-					struct nouveau_encoder *,
+enum drm_mode_status nv50_dp_mode_valid(struct nouveau_encoder *,
 					const struct drm_display_mode *,
 					unsigned *clock);
 
Signature · 1 line
2.41.0
#2 lore raw

PATCH 3/3 drm/nouveau/disp: verify mode on atomic_check

In reply to Karol Herbst

We have to verify the selected mode as Userspace might request one which we can't configure the GPU for.

X with the modesetting DDX is adding a bunch of modes, some so far outside of hardware limits that things simply break.

Sadly we can't fix X this way as on start it sticks to one mode and ignores any error and there is really nothing we can do about this, but at least this way we won't let the GPU run into any errors caused by a non supported display mode.

However this does prevent X from switching to such a mode, which to be fair is an improvement as well.

Seen on one of my Tesla GPUs with a connected 4K display.

---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +19 -0
index 22c42a5e184d..edf490c1490c 100644
@@ -1114,6 +1114,25 @@ nouveau_connector_atomic_check(struct drm_connector *connector, struct drm_atomi
 	struct drm_connector_state *conn_state =
 		drm_atomic_get_new_connector_state(state, connector);
 
+	/* As we can get any random mode from Userspace, we have to make sure the to be set mode
+	 * is valid and does not violate hardware constraints as we rely on it being sane.
+	 */
+	if (conn_state->crtc) {
+		struct drm_crtc_state *crtc_state =
+			drm_atomic_get_crtc_state(state, conn_state->crtc);
+
+		if (IS_ERR(crtc_state))
+			return PTR_ERR(crtc_state);
+
+		if (crtc_state->enable && (crtc_state->mode_changed ||
+					   crtc_state->connectors_changed)) {
+			struct drm_display_mode *mode = &crtc_state->mode;
+
+			if (connector->helper_private->mode_valid(connector, mode) != MODE_OK)
+				return -EINVAL;
+		}
+	}
+
 	if (!nv_conn->dp_encoder || !nv50_has_mst(nouveau_drm(connector->dev)))
 		return 0;
 
Signature · 1 line
2.41.0