drm/amd/display: Fix off-by-one error in DML
authorjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:19:12 +0000 (10:19 +0000)
committerjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:19:12 +0000 (10:19 +0000)
From Wesley Chalmers
c71de31b2e0f4ef71cc69ba841aeac12519b3607 in linux 5.10.y/5.10.51
e4e3678260e9734f6f41b4325aac0b171833a618 in mainline linux

sys/dev/pci/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c

index d66e892..2663f1b 100644 (file)
@@ -2053,7 +2053,7 @@ static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerforman
                        v->DISPCLKWithoutRamping,
                        v->DISPCLKDPPCLKVCOSpeed);
        v->MaxDispclkRoundedToDFSGranularity = RoundToDFSGranularityDown(
-                       v->soc.clock_limits[mode_lib->soc.num_states].dispclk_mhz,
+                       v->soc.clock_limits[mode_lib->soc.num_states - 1].dispclk_mhz,
                        v->DISPCLKDPPCLKVCOSpeed);
        if (v->DISPCLKWithoutRampingRoundedToDFSGranularity
                        > v->MaxDispclkRoundedToDFSGranularity) {
@@ -3958,20 +3958,20 @@ void dml30_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
                        for (k = 0; k <= v->NumberOfActivePlanes - 1; k++) {
                                v->PlaneRequiredDISPCLKWithoutODMCombine = v->PixelClock[k] * (1.0 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
                                                * (1.0 + v->DISPCLKRampingMargin / 100.0);
-                               if ((v->PlaneRequiredDISPCLKWithoutODMCombine >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states]
-                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states])) {
+                               if ((v->PlaneRequiredDISPCLKWithoutODMCombine >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states - 1]
+                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states - 1])) {
                                        v->PlaneRequiredDISPCLKWithoutODMCombine = v->PixelClock[k] * (1 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
                                }
                                v->PlaneRequiredDISPCLKWithODMCombine2To1 = v->PixelClock[k] / 2 * (1 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
                                                * (1 + v->DISPCLKRampingMargin / 100.0);
-                               if ((v->PlaneRequiredDISPCLKWithODMCombine2To1 >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states]
-                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states])) {
+                               if ((v->PlaneRequiredDISPCLKWithODMCombine2To1 >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states - 1]
+                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states - 1])) {
                                        v->PlaneRequiredDISPCLKWithODMCombine2To1 = v->PixelClock[k] / 2 * (1 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
                                }
                                v->PlaneRequiredDISPCLKWithODMCombine4To1 = v->PixelClock[k] / 4 * (1 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
                                                * (1 + v->DISPCLKRampingMargin / 100.0);
-                               if ((v->PlaneRequiredDISPCLKWithODMCombine4To1 >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states]
-                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states])) {
+                               if ((v->PlaneRequiredDISPCLKWithODMCombine4To1 >= v->MaxDispclk[i] && v->MaxDispclk[i] == v->MaxDispclk[mode_lib->soc.num_states - 1]
+                                               && v->MaxDppclk[i] == v->MaxDppclk[mode_lib->soc.num_states - 1])) {
                                        v->PlaneRequiredDISPCLKWithODMCombine4To1 = v->PixelClock[k] / 4 * (1 + v->DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
                                }