Skip to contentSkip to conversation

drm/nouveau: fix 64-bit divisor truncation in DP SST calculation

PATCH New Luděk Habarta 1 participant 1 message Nov 27

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

PATCH 1/1 drm/nouveau: fix 64-bit divisor truncation in DP SST calculation

The DP SST watermark calculation uses div_u64() to divide ratioF by the total link bandwidth. However, div_u64() takes a 32-bit divisor, while the calculated bandwidth can exceed U32_MAX.

For a four-lane HBR3 link, the divisor is 25920000000, which is truncated to 150196224. This results in ratioF exceeding PrecisionFactor and causes nv50_sor_dp_watermark_sst() to return prematurely without configuring the DP SST stream.

This was observed on an NVIDIA GA102 (GeForce RTX 3080) with GSP firmware 570.144 and a Dell AW5520QF connected via DisplayPort. Video output worked, but audio remained silent despite valid ELD data and successful ALSA playback.

Use div64_u64() to preserve the full 64-bit divisor, restoring the original arithmetic semantics before the conversion to kernel division helpers.

Tested on GA102 with Linux 7.3.6. DisplayPort audio works after the fix at 3840x2160 and 120 Hz.

Fixes 7e6bd6409b66 ("nouveau/disp: fix post-gsp build on 32-bit arm.")
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +1 -1
index e91130f93db6..7634147c01ac 100644
@@ -1661,7 +1661,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
 	//
 	ratioF = div_u64((u64)pixelClockHz * depth * PrecisionFactor, DSC_FACTOR);
 
-	ratioF = div_u64(ratioF, 8 * (u64) minRate * outp->dp.link_nr);
+	ratioF = div64_u64(ratioF, 8 * minRate * outp->dp.link_nr);
 
 	if (PrecisionFactor < ratioF) // Assert if we will end up with a negative number in below
 		return false;
Signature · 1 line
2.56.1