@@ -1327,55 +1327,63 @@ static void vlv_merge_wm(struct drm_i915_private *dev_priv,
1327
1327
}
1328
1328
}
1329
1329
1330
+ static bool is_disabling (int old , int new , int threshold )
1331
+ {
1332
+ return old >= threshold && new < threshold ;
1333
+ }
1334
+
1335
+ static bool is_enabling (int old , int new , int threshold )
1336
+ {
1337
+ return old < threshold && new >= threshold ;
1338
+ }
1339
+
1330
1340
static void vlv_update_wm (struct intel_crtc * crtc )
1331
1341
{
1332
1342
struct drm_i915_private * dev_priv = to_i915 (crtc -> base .dev );
1333
1343
enum pipe pipe = crtc -> pipe ;
1334
- struct vlv_wm_values wm = {};
1344
+ struct vlv_wm_values * old_wm = & dev_priv -> wm .vlv ;
1345
+ struct vlv_wm_values new_wm = {};
1335
1346
1336
1347
vlv_compute_wm (crtc );
1337
- vlv_merge_wm (dev_priv , & wm );
1348
+ vlv_merge_wm (dev_priv , & new_wm );
1338
1349
1339
- if (memcmp (& dev_priv -> wm . vlv , & wm , sizeof (wm )) == 0 ) {
1350
+ if (memcmp (old_wm , & new_wm , sizeof (new_wm )) == 0 ) {
1340
1351
/* FIXME should be part of crtc atomic commit */
1341
1352
vlv_pipe_set_fifo_size (crtc );
1353
+
1342
1354
return ;
1343
1355
}
1344
1356
1345
- if (wm .level < VLV_WM_LEVEL_DDR_DVFS &&
1346
- dev_priv -> wm .vlv .level >= VLV_WM_LEVEL_DDR_DVFS )
1357
+ if (is_disabling (old_wm -> level , new_wm .level , VLV_WM_LEVEL_DDR_DVFS ))
1347
1358
chv_set_memory_dvfs (dev_priv , false);
1348
1359
1349
- if (wm .level < VLV_WM_LEVEL_PM5 &&
1350
- dev_priv -> wm .vlv .level >= VLV_WM_LEVEL_PM5 )
1360
+ if (is_disabling (old_wm -> level , new_wm .level , VLV_WM_LEVEL_PM5 ))
1351
1361
chv_set_memory_pm5 (dev_priv , false);
1352
1362
1353
- if (! wm . cxsr && dev_priv -> wm . vlv . cxsr )
1363
+ if (is_disabling ( old_wm -> cxsr , new_wm . cxsr , true) )
1354
1364
_intel_set_memory_cxsr (dev_priv , false);
1355
1365
1356
1366
/* FIXME should be part of crtc atomic commit */
1357
1367
vlv_pipe_set_fifo_size (crtc );
1358
1368
1359
- vlv_write_wm_values (dev_priv , & wm );
1369
+ vlv_write_wm_values (dev_priv , & new_wm );
1360
1370
1361
1371
DRM_DEBUG_KMS ("Setting FIFO watermarks - %c: plane=%d, cursor=%d, "
1362
1372
"sprite0=%d, sprite1=%d, SR: plane=%d, cursor=%d level=%d cxsr=%d\n" ,
1363
- pipe_name (pipe ), wm .pipe [pipe ].plane [PLANE_PRIMARY ], wm .pipe [pipe ].plane [PLANE_CURSOR ],
1364
- wm .pipe [pipe ].plane [PLANE_SPRITE0 ], wm .pipe [pipe ].plane [PLANE_SPRITE1 ],
1365
- wm .sr .plane , wm .sr .cursor , wm .level , wm .cxsr );
1373
+ pipe_name (pipe ), new_wm .pipe [pipe ].plane [PLANE_PRIMARY ], new_wm .pipe [pipe ].plane [PLANE_CURSOR ],
1374
+ new_wm .pipe [pipe ].plane [PLANE_SPRITE0 ], new_wm .pipe [pipe ].plane [PLANE_SPRITE1 ],
1375
+ new_wm .sr .plane , new_wm .sr .cursor , new_wm .level , new_wm .cxsr );
1366
1376
1367
- if (wm . cxsr && ! dev_priv -> wm . vlv . cxsr )
1377
+ if (is_enabling ( old_wm -> cxsr , new_wm . cxsr , true) )
1368
1378
_intel_set_memory_cxsr (dev_priv , true);
1369
1379
1370
- if (wm .level >= VLV_WM_LEVEL_PM5 &&
1371
- dev_priv -> wm .vlv .level < VLV_WM_LEVEL_PM5 )
1380
+ if (is_enabling (old_wm -> level , new_wm .level , VLV_WM_LEVEL_PM5 ))
1372
1381
chv_set_memory_pm5 (dev_priv , true);
1373
1382
1374
- if (wm .level >= VLV_WM_LEVEL_DDR_DVFS &&
1375
- dev_priv -> wm .vlv .level < VLV_WM_LEVEL_DDR_DVFS )
1383
+ if (is_enabling (old_wm -> level , new_wm .level , VLV_WM_LEVEL_DDR_DVFS ))
1376
1384
chv_set_memory_dvfs (dev_priv , true);
1377
1385
1378
- dev_priv -> wm . vlv = wm ;
1386
+ * old_wm = new_wm ;
1379
1387
}
1380
1388
1381
1389
#define single_plane_enabled (mask ) is_power_of_2(mask)
0 commit comments