Skip to content

Commit 7e6bd64

Browse files
committed
nouveau/disp: fix post-gsp build on 32-bit arm.
This converts a bunch of divides into the proper macros. Reviewed-by: Danilo Krummrich <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent b76827a commit 7e6bd64

File tree

1 file changed

+13
-11
lines changed
  • drivers/gpu/drm/nouveau/dispnv50

1 file changed

+13
-11
lines changed

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
16441644
// 0 active symbols. This may cause HW hang. Bug 200379426
16451645
//
16461646
if ((bEnableDsc) &&
1647-
((pixelClockHz * depth) < ((8 * minRate * outp->dp.link_nr * DSC_FACTOR) / 64)))
1647+
((pixelClockHz * depth) < div_u64(8 * minRate * outp->dp.link_nr * DSC_FACTOR, 64)))
16481648
{
16491649
return false;
16501650
}
@@ -1654,20 +1654,20 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
16541654
// For auto mode the watermark calculation does not need to track accumulated error the
16551655
// formulas for manual mode will not work. So below calculation was extracted from the DTB.
16561656
//
1657-
ratioF = ((u64)pixelClockHz * depth * PrecisionFactor) / DSC_FACTOR;
1657+
ratioF = div_u64((u64)pixelClockHz * depth * PrecisionFactor, DSC_FACTOR);
16581658

1659-
ratioF /= 8 * (u64) minRate * outp->dp.link_nr;
1659+
ratioF = div_u64(ratioF, 8 * (u64) minRate * outp->dp.link_nr);
16601660

16611661
if (PrecisionFactor < ratioF) // Assert if we will end up with a negative number in below
16621662
return false;
16631663

1664-
watermarkF = ratioF * tuSize * (PrecisionFactor - ratioF) / PrecisionFactor;
1665-
waterMark = (unsigned)(watermarkAdjust + ((2 * (depth * PrecisionFactor / (8 * numLanesPerLink * DSC_FACTOR)) + watermarkF) / PrecisionFactor));
1664+
watermarkF = div_u64(ratioF * tuSize * (PrecisionFactor - ratioF), PrecisionFactor);
1665+
waterMark = (unsigned)(watermarkAdjust + (div_u64(2 * div_u64(depth * PrecisionFactor, 8 * numLanesPerLink * DSC_FACTOR) + watermarkF, PrecisionFactor)));
16661666

16671667
//
16681668
// Bounds check the watermark
16691669
//
1670-
numSymbolsPerLine = (surfaceWidth * depth) / (8 * outp->dp.link_nr * DSC_FACTOR);
1670+
numSymbolsPerLine = div_u64(surfaceWidth * depth, 8 * outp->dp.link_nr * DSC_FACTOR);
16711671

16721672
if (WARN_ON(waterMark > 39 || waterMark > numSymbolsPerLine))
16731673
return false;
@@ -1688,11 +1688,13 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
16881688
surfaceWidthPerLink = surfaceWidth;
16891689

16901690
//Extra bits sent due to pixel steering
1691-
PixelSteeringBits = (surfaceWidthPerLink % numLanesPerLink) ? (((numLanesPerLink - surfaceWidthPerLink % numLanesPerLink) * depth) / DSC_FACTOR) : 0;
1691+
u32 remain;
1692+
div_u64_rem(surfaceWidthPerLink, numLanesPerLink, &remain);
1693+
PixelSteeringBits = remain ? div_u64((numLanesPerLink - remain) * depth, DSC_FACTOR) : 0;
16921694

16931695
BlankingBits += PixelSteeringBits;
1694-
NumBlankingLinkClocks = (u64)BlankingBits * PrecisionFactor / (8 * numLanesPerLink);
1695-
MinHBlank = (u32)(NumBlankingLinkClocks * pixelClockHz/ minRate / PrecisionFactor);
1696+
NumBlankingLinkClocks = div_u64((u64)BlankingBits * PrecisionFactor, (8 * numLanesPerLink));
1697+
MinHBlank = (u32)(div_u64(div_u64(NumBlankingLinkClocks * pixelClockHz, minRate), PrecisionFactor));
16961698
MinHBlank += 12;
16971699

16981700
if (WARN_ON(MinHBlank > rasterWidth - surfaceWidth))
@@ -1703,7 +1705,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
17031705
return false;
17041706

17051707

1706-
hblank_symbols = (s32)(((u64)(rasterWidth - surfaceWidth - MinHBlank) * minRate) / pixelClockHz);
1708+
hblank_symbols = (s32)(div_u64((u64)(rasterWidth - surfaceWidth - MinHBlank) * minRate, pixelClockHz));
17071709

17081710
//reduce HBlank Symbols to account for secondary data packet
17091711
hblank_symbols -= 1; //Stuffer latency to send BS
@@ -1722,7 +1724,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
17221724
}
17231725
else
17241726
{
1725-
vblank_symbols = (s32)(((u64)(surfaceWidth - 40) * minRate) / pixelClockHz) - 1;
1727+
vblank_symbols = (s32)((div_u64((u64)(surfaceWidth - 40) * minRate, pixelClockHz))) - 1;
17261728

17271729
vblank_symbols -= numLanesPerLink == 1 ? 39 : numLanesPerLink == 2 ? 21 : 12;
17281730
}

0 commit comments

Comments
 (0)