Subversion Repositories Kolibri OS

Rev

Rev 3120 | Rev 3480 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3120 Rev 3243
Line 61... Line 61...
61
 *
61
 *
62
 * FBC-related functionality can be enabled by the means of the
62
 * FBC-related functionality can be enabled by the means of the
63
 * i915.i915_enable_fbc parameter
63
 * i915.i915_enable_fbc parameter
64
 */
64
 */
Line -... Line 65...
-
 
65
 
-
 
66
static bool intel_crtc_active(struct drm_crtc *crtc)
-
 
67
{
-
 
68
	/* Be paranoid as we can arrive here with only partial
-
 
69
	 * state retrieved from the hardware during setup.
-
 
70
	 */
-
 
71
	return to_intel_crtc(crtc)->active && crtc->fb && crtc->mode.clock;
-
 
72
}
65
 
73
 
66
static void i8xx_disable_fbc(struct drm_device *dev)
74
static void i8xx_disable_fbc(struct drm_device *dev)
67
{
75
{
68
	struct drm_i915_private *dev_priv = dev->dev_private;
76
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 426... Line 434...
426
	 *   - changing FBC params (stride, fence, mode)
434
	 *   - changing FBC params (stride, fence, mode)
427
	 *   - new fb is too large to fit in compressed buffer
435
	 *   - new fb is too large to fit in compressed buffer
428
	 *   - going to an unsupported config (interlace, pixel multiply, etc.)
436
	 *   - going to an unsupported config (interlace, pixel multiply, etc.)
429
	 */
437
	 */
430
	list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) {
438
	list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) {
431
		if (tmp_crtc->enabled &&
439
		if (intel_crtc_active(tmp_crtc) &&
432
		    !to_intel_crtc(tmp_crtc)->primary_disabled &&
440
		    !to_intel_crtc(tmp_crtc)->primary_disabled) {
433
		    tmp_crtc->fb) {
-
 
434
			if (crtc) {
441
			if (crtc) {
435
				DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
442
				DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
436
				dev_priv->no_fbc_reason = FBC_MULTIPLE_PIPES;
443
				dev_priv->no_fbc_reason = FBC_MULTIPLE_PIPES;
437
				goto out_disable;
444
				goto out_disable;
438
			}
445
			}
Line 1013... Line 1020...
1013
static struct drm_crtc *single_enabled_crtc(struct drm_device *dev)
1020
static struct drm_crtc *single_enabled_crtc(struct drm_device *dev)
1014
{
1021
{
1015
	struct drm_crtc *crtc, *enabled = NULL;
1022
	struct drm_crtc *crtc, *enabled = NULL;
Line 1016... Line 1023...
1016
 
1023
 
1017
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1024
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1018
		if (crtc->enabled && crtc->fb) {
1025
		if (intel_crtc_active(crtc)) {
1019
			if (enabled)
1026
			if (enabled)
1020
				return NULL;
1027
				return NULL;
1021
			enabled = crtc;
1028
			enabled = crtc;
1022
		}
1029
		}
Line 1107... Line 1114...
1107
	int htotal, hdisplay, clock, pixel_size;
1114
	int htotal, hdisplay, clock, pixel_size;
1108
	int line_time_us, line_count;
1115
	int line_time_us, line_count;
1109
	int entries, tlb_miss;
1116
	int entries, tlb_miss;
Line 1110... Line 1117...
1110
 
1117
 
1111
	crtc = intel_get_crtc_for_plane(dev, plane);
1118
	crtc = intel_get_crtc_for_plane(dev, plane);
1112
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
1113
 
-
 
1114
    if (crtc->fb == NULL || !crtc->enabled || !intel_crtc->active) {
1119
	if (!intel_crtc_active(crtc)) {
1115
		*cursor_wm = cursor->guard_size;
1120
		*cursor_wm = cursor->guard_size;
1116
		*plane_wm = display->guard_size;
1121
		*plane_wm = display->guard_size;
1117
        return false;
1122
        return false;
Line 1238... Line 1243...
1238
	struct drm_crtc *crtc;
1243
	struct drm_crtc *crtc;
1239
	int clock, pixel_size;
1244
	int clock, pixel_size;
1240
	int entries;
1245
	int entries;
Line 1241... Line 1246...
1241
 
1246
 
1242
	crtc = intel_get_crtc_for_plane(dev, plane);
1247
	crtc = intel_get_crtc_for_plane(dev, plane);
1243
	if (crtc->fb == NULL || !crtc->enabled)
1248
	if (!intel_crtc_active(crtc))
Line 1244... Line 1249...
1244
		return false;
1249
		return false;
1245
 
1250
 
Line 1309... Line 1314...
1309
{
1314
{
1310
	static const int sr_latency_ns = 12000;
1315
	static const int sr_latency_ns = 12000;
1311
	struct drm_i915_private *dev_priv = dev->dev_private;
1316
	struct drm_i915_private *dev_priv = dev->dev_private;
1312
	int planea_wm, planeb_wm, cursora_wm, cursorb_wm;
1317
	int planea_wm, planeb_wm, cursora_wm, cursorb_wm;
1313
	int plane_sr, cursor_sr;
1318
	int plane_sr, cursor_sr;
-
 
1319
	int ignore_plane_sr, ignore_cursor_sr;
1314
	unsigned int enabled = 0;
1320
	unsigned int enabled = 0;
Line 1315... Line 1321...
1315
 
1321
 
Line 1316... Line 1322...
1316
	vlv_update_drain_latency(dev);
1322
	vlv_update_drain_latency(dev);
Line 1325... Line 1331...
1325
			    &valleyview_wm_info, latency_ns,
1331
			    &valleyview_wm_info, latency_ns,
1326
			    &valleyview_cursor_wm_info, latency_ns,
1332
			    &valleyview_cursor_wm_info, latency_ns,
1327
			    &planeb_wm, &cursorb_wm))
1333
			    &planeb_wm, &cursorb_wm))
1328
		enabled |= 2;
1334
		enabled |= 2;
Line 1329... Line -...
1329
 
-
 
1330
	plane_sr = cursor_sr = 0;
1335
 
1331
	if (single_plane_enabled(enabled) &&
1336
	if (single_plane_enabled(enabled) &&
1332
	    g4x_compute_srwm(dev, ffs(enabled) - 1,
1337
	    g4x_compute_srwm(dev, ffs(enabled) - 1,
1333
			     sr_latency_ns,
1338
			     sr_latency_ns,
1334
			     &valleyview_wm_info,
1339
			     &valleyview_wm_info,
-
 
1340
			     &valleyview_cursor_wm_info,
-
 
1341
			     &plane_sr, &ignore_cursor_sr) &&
-
 
1342
	    g4x_compute_srwm(dev, ffs(enabled) - 1,
-
 
1343
			     2*sr_latency_ns,
-
 
1344
			     &valleyview_wm_info,
1335
			     &valleyview_cursor_wm_info,
1345
			     &valleyview_cursor_wm_info,
1336
			     &plane_sr, &cursor_sr))
1346
			     &ignore_plane_sr, &cursor_sr)) {
1337
		I915_WRITE(FW_BLC_SELF_VLV, FW_CSPWRDWNEN);
1347
		I915_WRITE(FW_BLC_SELF_VLV, FW_CSPWRDWNEN);
1338
	else
1348
	} else {
1339
		I915_WRITE(FW_BLC_SELF_VLV,
1349
		I915_WRITE(FW_BLC_SELF_VLV,
-
 
1350
			   I915_READ(FW_BLC_SELF_VLV) & ~FW_CSPWRDWNEN);
-
 
1351
		plane_sr = cursor_sr = 0;
Line 1340... Line 1352...
1340
			   I915_READ(FW_BLC_SELF_VLV) & ~FW_CSPWRDWNEN);
1352
	}
1341
 
1353
 
1342
	DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%d, cursor=%d, B: plane=%d, cursor=%d, SR: plane=%d, cursor=%d\n",
1354
	DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%d, cursor=%d, B: plane=%d, cursor=%d, SR: plane=%d, cursor=%d\n",
1343
		      planea_wm, cursora_wm,
1355
		      planea_wm, cursora_wm,
Line 1348... Line 1360...
1348
		   (plane_sr << DSPFW_SR_SHIFT) |
1360
		   (plane_sr << DSPFW_SR_SHIFT) |
1349
		   (cursorb_wm << DSPFW_CURSORB_SHIFT) |
1361
		   (cursorb_wm << DSPFW_CURSORB_SHIFT) |
1350
		   (planeb_wm << DSPFW_PLANEB_SHIFT) |
1362
		   (planeb_wm << DSPFW_PLANEB_SHIFT) |
1351
		   planea_wm);
1363
		   planea_wm);
1352
	I915_WRITE(DSPFW2,
1364
	I915_WRITE(DSPFW2,
1353
		   (I915_READ(DSPFW2) & DSPFW_CURSORA_MASK) |
1365
		   (I915_READ(DSPFW2) & ~DSPFW_CURSORA_MASK) |
1354
		   (cursora_wm << DSPFW_CURSORA_SHIFT));
1366
		   (cursora_wm << DSPFW_CURSORA_SHIFT));
1355
	I915_WRITE(DSPFW3,
1367
	I915_WRITE(DSPFW3,
1356
		   (I915_READ(DSPFW3) | (cursor_sr << DSPFW_CURSOR_SR_SHIFT)));
1368
		   (I915_READ(DSPFW3) & ~DSPFW_CURSOR_SR_MASK) |
-
 
1369
		   (cursor_sr << DSPFW_CURSOR_SR_SHIFT));
1357
}
1370
}
Line 1358... Line 1371...
1358
 
1371
 
1359
static void g4x_update_wm(struct drm_device *dev)
1372
static void g4x_update_wm(struct drm_device *dev)
1360
{
1373
{
Line 1374... Line 1387...
1374
			    &g4x_wm_info, latency_ns,
1387
			    &g4x_wm_info, latency_ns,
1375
			    &g4x_cursor_wm_info, latency_ns,
1388
			    &g4x_cursor_wm_info, latency_ns,
1376
			    &planeb_wm, &cursorb_wm))
1389
			    &planeb_wm, &cursorb_wm))
1377
		enabled |= 2;
1390
		enabled |= 2;
Line 1378... Line -...
1378
 
-
 
1379
	plane_sr = cursor_sr = 0;
1391
 
1380
	if (single_plane_enabled(enabled) &&
1392
	if (single_plane_enabled(enabled) &&
1381
	    g4x_compute_srwm(dev, ffs(enabled) - 1,
1393
	    g4x_compute_srwm(dev, ffs(enabled) - 1,
1382
			     sr_latency_ns,
1394
			     sr_latency_ns,
1383
			     &g4x_wm_info,
1395
			     &g4x_wm_info,
1384
			     &g4x_cursor_wm_info,
1396
			     &g4x_cursor_wm_info,
1385
			     &plane_sr, &cursor_sr))
1397
			     &plane_sr, &cursor_sr)) {
1386
		I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
1398
		I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
1387
	else
1399
	} else {
1388
		I915_WRITE(FW_BLC_SELF,
1400
		I915_WRITE(FW_BLC_SELF,
-
 
1401
			   I915_READ(FW_BLC_SELF) & ~FW_BLC_SELF_EN);
-
 
1402
		plane_sr = cursor_sr = 0;
Line 1389... Line 1403...
1389
			   I915_READ(FW_BLC_SELF) & ~FW_BLC_SELF_EN);
1403
	}
1390
 
1404
 
1391
	DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%d, cursor=%d, B: plane=%d, cursor=%d, SR: plane=%d, cursor=%d\n",
1405
	DRM_DEBUG_KMS("Setting FIFO watermarks - A: plane=%d, cursor=%d, B: plane=%d, cursor=%d, SR: plane=%d, cursor=%d\n",
1392
		      planea_wm, cursora_wm,
1406
		      planea_wm, cursora_wm,
Line 1397... Line 1411...
1397
		   (plane_sr << DSPFW_SR_SHIFT) |
1411
		   (plane_sr << DSPFW_SR_SHIFT) |
1398
		   (cursorb_wm << DSPFW_CURSORB_SHIFT) |
1412
		   (cursorb_wm << DSPFW_CURSORB_SHIFT) |
1399
		   (planeb_wm << DSPFW_PLANEB_SHIFT) |
1413
		   (planeb_wm << DSPFW_PLANEB_SHIFT) |
1400
		   planea_wm);
1414
		   planea_wm);
1401
	I915_WRITE(DSPFW2,
1415
	I915_WRITE(DSPFW2,
1402
		   (I915_READ(DSPFW2) & DSPFW_CURSORA_MASK) |
1416
		   (I915_READ(DSPFW2) & ~DSPFW_CURSORA_MASK) |
1403
		   (cursora_wm << DSPFW_CURSORA_SHIFT));
1417
		   (cursora_wm << DSPFW_CURSORA_SHIFT));
1404
	/* HPLL off in SR has some issues on G4x... disable it */
1418
	/* HPLL off in SR has some issues on G4x... disable it */
1405
	I915_WRITE(DSPFW3,
1419
	I915_WRITE(DSPFW3,
1406
		   (I915_READ(DSPFW3) & ~DSPFW_HPLL_SR_EN) |
1420
		   (I915_READ(DSPFW3) & ~(DSPFW_HPLL_SR_EN | DSPFW_CURSOR_SR_MASK)) |
1407
		   (cursor_sr << DSPFW_CURSOR_SR_SHIFT));
1421
		   (cursor_sr << DSPFW_CURSOR_SR_SHIFT));
1408
}
1422
}
Line 1409... Line 1423...
1409
 
1423
 
1410
static void i965_update_wm(struct drm_device *dev)
1424
static void i965_update_wm(struct drm_device *dev)
Line 1490... Line 1504...
1490
	else
1504
	else
1491
		wm_info = &i855_wm_info;
1505
		wm_info = &i855_wm_info;
Line 1492... Line 1506...
1492
 
1506
 
1493
	fifo_size = dev_priv->display.get_fifo_size(dev, 0);
1507
	fifo_size = dev_priv->display.get_fifo_size(dev, 0);
1494
	crtc = intel_get_crtc_for_plane(dev, 0);
1508
	crtc = intel_get_crtc_for_plane(dev, 0);
-
 
1509
	if (intel_crtc_active(crtc)) {
-
 
1510
		int cpp = crtc->fb->bits_per_pixel / 8;
-
 
1511
		if (IS_GEN2(dev))
-
 
1512
			cpp = 4;
1495
	if (crtc->enabled && crtc->fb) {
1513
 
1496
		planea_wm = intel_calculate_wm(crtc->mode.clock,
1514
		planea_wm = intel_calculate_wm(crtc->mode.clock,
1497
					       wm_info, fifo_size,
-
 
1498
					       crtc->fb->bits_per_pixel / 8,
1515
					       wm_info, fifo_size, cpp,
1499
					       latency_ns);
1516
					       latency_ns);
1500
		enabled = crtc;
1517
		enabled = crtc;
1501
	} else
1518
	} else
Line 1502... Line 1519...
1502
		planea_wm = fifo_size - wm_info->guard_size;
1519
		planea_wm = fifo_size - wm_info->guard_size;
1503
 
1520
 
1504
	fifo_size = dev_priv->display.get_fifo_size(dev, 1);
1521
	fifo_size = dev_priv->display.get_fifo_size(dev, 1);
-
 
1522
	crtc = intel_get_crtc_for_plane(dev, 1);
-
 
1523
	if (intel_crtc_active(crtc)) {
-
 
1524
		int cpp = crtc->fb->bits_per_pixel / 8;
-
 
1525
		if (IS_GEN2(dev))
1505
	crtc = intel_get_crtc_for_plane(dev, 1);
1526
			cpp = 4;
1506
	if (crtc->enabled && crtc->fb) {
1527
 
1507
		planeb_wm = intel_calculate_wm(crtc->mode.clock,
-
 
1508
					       wm_info, fifo_size,
1528
		planeb_wm = intel_calculate_wm(crtc->mode.clock,
1509
					       crtc->fb->bits_per_pixel / 8,
1529
					       wm_info, fifo_size, cpp,
1510
					       latency_ns);
1530
					       latency_ns);
1511
		if (enabled == NULL)
1531
		if (enabled == NULL)
1512
			enabled = crtc;
1532
			enabled = crtc;
Line 1594... Line 1614...
1594
	if (crtc == NULL)
1614
	if (crtc == NULL)
1595
		return;
1615
		return;
Line 1596... Line 1616...
1596
 
1616
 
1597
	planea_wm = intel_calculate_wm(crtc->mode.clock, &i830_wm_info,
1617
	planea_wm = intel_calculate_wm(crtc->mode.clock, &i830_wm_info,
1598
				       dev_priv->display.get_fifo_size(dev, 0),
-
 
1599
				       crtc->fb->bits_per_pixel / 8,
1618
				       dev_priv->display.get_fifo_size(dev, 0),
1600
				       latency_ns);
1619
				       4, latency_ns);
1601
	fwater_lo = I915_READ(FW_BLC) & ~0xfff;
1620
	fwater_lo = I915_READ(FW_BLC) & ~0xfff;
Line 1602... Line 1621...
1602
	fwater_lo |= (3<<8) | planea_wm;
1621
	fwater_lo |= (3<<8) | planea_wm;
Line 1828... Line 1847...
1828
			      " plane %d, cursor: %d\n",
1847
			      " plane %d, cursor: %d\n",
1829
			      plane_wm, cursor_wm);
1848
			      plane_wm, cursor_wm);
1830
		enabled |= 2;
1849
		enabled |= 2;
1831
	}
1850
	}
Line -... Line 1851...
-
 
1851
 
-
 
1852
	/*
-
 
1853
	 * Calculate and update the self-refresh watermark only when one
-
 
1854
	 * display plane is used.
-
 
1855
	 *
-
 
1856
	 * SNB support 3 levels of watermark.
-
 
1857
	 *
-
 
1858
	 * WM1/WM2/WM2 watermarks have to be enabled in the ascending order,
-
 
1859
	 * and disabled in the descending order
-
 
1860
	 *
-
 
1861
	 */
-
 
1862
	I915_WRITE(WM3_LP_ILK, 0);
-
 
1863
	I915_WRITE(WM2_LP_ILK, 0);
-
 
1864
	I915_WRITE(WM1_LP_ILK, 0);
-
 
1865
 
1832
 
1866
	if (!single_plane_enabled(enabled) ||
-
 
1867
	    dev_priv->sprite_scaling_enabled)
-
 
1868
		return;
-
 
1869
	enabled = ffs(enabled) - 1;
-
 
1870
 
-
 
1871
	/* WM1 */
-
 
1872
	if (!ironlake_compute_srwm(dev, 1, enabled,
-
 
1873
				   SNB_READ_WM1_LATENCY() * 500,
-
 
1874
				   &sandybridge_display_srwm_info,
-
 
1875
				   &sandybridge_cursor_srwm_info,
-
 
1876
				   &fbc_wm, &plane_wm, &cursor_wm))
-
 
1877
		return;
-
 
1878
 
-
 
1879
	I915_WRITE(WM1_LP_ILK,
-
 
1880
		   WM1_LP_SR_EN |
-
 
1881
		   (SNB_READ_WM1_LATENCY() << WM1_LP_LATENCY_SHIFT) |
-
 
1882
		   (fbc_wm << WM1_LP_FBC_SHIFT) |
-
 
1883
		   (plane_wm << WM1_LP_SR_SHIFT) |
-
 
1884
		   cursor_wm);
-
 
1885
 
-
 
1886
	/* WM2 */
-
 
1887
	if (!ironlake_compute_srwm(dev, 2, enabled,
-
 
1888
				   SNB_READ_WM2_LATENCY() * 500,
-
 
1889
				   &sandybridge_display_srwm_info,
-
 
1890
				   &sandybridge_cursor_srwm_info,
-
 
1891
				   &fbc_wm, &plane_wm, &cursor_wm))
-
 
1892
		return;
-
 
1893
 
-
 
1894
	I915_WRITE(WM2_LP_ILK,
-
 
1895
		   WM2_LP_EN |
-
 
1896
		   (SNB_READ_WM2_LATENCY() << WM1_LP_LATENCY_SHIFT) |
-
 
1897
		   (fbc_wm << WM1_LP_FBC_SHIFT) |
-
 
1898
		   (plane_wm << WM1_LP_SR_SHIFT) |
-
 
1899
		   cursor_wm);
-
 
1900
 
-
 
1901
	/* WM3 */
-
 
1902
	if (!ironlake_compute_srwm(dev, 3, enabled,
-
 
1903
				   SNB_READ_WM3_LATENCY() * 500,
-
 
1904
				   &sandybridge_display_srwm_info,
-
 
1905
				   &sandybridge_cursor_srwm_info,
-
 
1906
				   &fbc_wm, &plane_wm, &cursor_wm))
-
 
1907
		return;
-
 
1908
 
-
 
1909
	I915_WRITE(WM3_LP_ILK,
-
 
1910
		   WM3_LP_EN |
-
 
1911
		   (SNB_READ_WM3_LATENCY() << WM1_LP_LATENCY_SHIFT) |
-
 
1912
		   (fbc_wm << WM1_LP_FBC_SHIFT) |
-
 
1913
		   (plane_wm << WM1_LP_SR_SHIFT) |
-
 
1914
		   cursor_wm);
-
 
1915
}
-
 
1916
 
-
 
1917
static void ivybridge_update_wm(struct drm_device *dev)
-
 
1918
{
-
 
1919
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1920
	int latency = SNB_READ_WM0_LATENCY() * 100;	/* In unit 0.1us */
-
 
1921
	u32 val;
-
 
1922
	int fbc_wm, plane_wm, cursor_wm;
-
 
1923
	int ignore_fbc_wm, ignore_plane_wm, ignore_cursor_wm;
-
 
1924
	unsigned int enabled;
-
 
1925
 
-
 
1926
	enabled = 0;
-
 
1927
	if (g4x_compute_wm0(dev, 0,
-
 
1928
			    &sandybridge_display_wm_info, latency,
-
 
1929
			    &sandybridge_cursor_wm_info, latency,
-
 
1930
			    &plane_wm, &cursor_wm)) {
-
 
1931
		val = I915_READ(WM0_PIPEA_ILK);
-
 
1932
		val &= ~(WM0_PIPE_PLANE_MASK | WM0_PIPE_CURSOR_MASK);
-
 
1933
		I915_WRITE(WM0_PIPEA_ILK, val |
-
 
1934
			   ((plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm));
-
 
1935
		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
-
 
1936
			      " plane %d, " "cursor: %d\n",
-
 
1937
			      plane_wm, cursor_wm);
-
 
1938
		enabled |= 1;
-
 
1939
	}
-
 
1940
 
-
 
1941
	if (g4x_compute_wm0(dev, 1,
-
 
1942
			    &sandybridge_display_wm_info, latency,
-
 
1943
			    &sandybridge_cursor_wm_info, latency,
-
 
1944
			    &plane_wm, &cursor_wm)) {
-
 
1945
		val = I915_READ(WM0_PIPEB_ILK);
-
 
1946
		val &= ~(WM0_PIPE_PLANE_MASK | WM0_PIPE_CURSOR_MASK);
-
 
1947
		I915_WRITE(WM0_PIPEB_ILK, val |
-
 
1948
			   ((plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm));
-
 
1949
		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
-
 
1950
			      " plane %d, cursor: %d\n",
-
 
1951
			      plane_wm, cursor_wm);
-
 
1952
		enabled |= 2;
-
 
1953
	}
1833
	if ((dev_priv->num_pipe == 3) &&
1954
 
1834
	    g4x_compute_wm0(dev, 2,
1955
	if (g4x_compute_wm0(dev, 2,
1835
			    &sandybridge_display_wm_info, latency,
1956
			    &sandybridge_display_wm_info, latency,
1836
			    &sandybridge_cursor_wm_info, latency,
1957
			    &sandybridge_cursor_wm_info, latency,
1837
			    &plane_wm, &cursor_wm)) {
1958
			    &plane_wm, &cursor_wm)) {
1838
		val = I915_READ(WM0_PIPEC_IVB);
1959
		val = I915_READ(WM0_PIPEC_IVB);
Line 1892... Line 2013...
1892
		   (SNB_READ_WM2_LATENCY() << WM1_LP_LATENCY_SHIFT) |
2013
		   (SNB_READ_WM2_LATENCY() << WM1_LP_LATENCY_SHIFT) |
1893
		   (fbc_wm << WM1_LP_FBC_SHIFT) |
2014
		   (fbc_wm << WM1_LP_FBC_SHIFT) |
1894
		   (plane_wm << WM1_LP_SR_SHIFT) |
2015
		   (plane_wm << WM1_LP_SR_SHIFT) |
1895
		   cursor_wm);
2016
		   cursor_wm);
Line 1896... Line 2017...
1896
 
2017
 
1897
	/* WM3 */
2018
	/* WM3, note we have to correct the cursor latency */
1898
	if (!ironlake_compute_srwm(dev, 3, enabled,
2019
	if (!ironlake_compute_srwm(dev, 3, enabled,
1899
				   SNB_READ_WM3_LATENCY() * 500,
2020
				   SNB_READ_WM3_LATENCY() * 500,
1900
				   &sandybridge_display_srwm_info,
2021
				   &sandybridge_display_srwm_info,
1901
				   &sandybridge_cursor_srwm_info,
2022
				   &sandybridge_cursor_srwm_info,
-
 
2023
				   &fbc_wm, &plane_wm, &ignore_cursor_wm) ||
-
 
2024
	    !ironlake_compute_srwm(dev, 3, enabled,
-
 
2025
				   2 * SNB_READ_WM3_LATENCY() * 500,
-
 
2026
				   &sandybridge_display_srwm_info,
-
 
2027
				   &sandybridge_cursor_srwm_info,
1902
				   &fbc_wm, &plane_wm, &cursor_wm))
2028
				   &ignore_fbc_wm, &ignore_plane_wm, &cursor_wm))
Line 1903... Line 2029...
1903
		return;
2029
		return;
1904
 
2030
 
1905
	I915_WRITE(WM3_LP_ILK,
2031
	I915_WRITE(WM3_LP_ILK,
Line 1946... Line 2072...
1946
	struct drm_crtc *crtc;
2072
	struct drm_crtc *crtc;
1947
	int clock;
2073
	int clock;
1948
	int entries, tlb_miss;
2074
	int entries, tlb_miss;
Line 1949... Line 2075...
1949
 
2075
 
1950
	crtc = intel_get_crtc_for_plane(dev, plane);
2076
	crtc = intel_get_crtc_for_plane(dev, plane);
1951
	if (crtc->fb == NULL || !crtc->enabled) {
2077
	if (!intel_crtc_active(crtc)) {
1952
		*sprite_wm = display->guard_size;
2078
		*sprite_wm = display->guard_size;
1953
		return false;
2079
		return false;
Line 1954... Line 2080...
1954
	}
2080
	}
Line 2346... Line 2472...
2346
void gen6_set_rps(struct drm_device *dev, u8 val)
2472
void gen6_set_rps(struct drm_device *dev, u8 val)
2347
{
2473
{
2348
	struct drm_i915_private *dev_priv = dev->dev_private;
2474
	struct drm_i915_private *dev_priv = dev->dev_private;
2349
	u32 limits = gen6_rps_limits(dev_priv, &val);
2475
	u32 limits = gen6_rps_limits(dev_priv, &val);
Line 2350... Line 2476...
2350
 
2476
 
2351
	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
2477
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
2352
	WARN_ON(val > dev_priv->rps.max_delay);
2478
	WARN_ON(val > dev_priv->rps.max_delay);
Line 2353... Line 2479...
2353
	WARN_ON(val < dev_priv->rps.min_delay);
2479
	WARN_ON(val < dev_priv->rps.min_delay);
2354
 
2480
 
Line 2421... Line 2547...
2421
{
2547
{
2422
	struct drm_i915_private *dev_priv = dev->dev_private;
2548
	struct drm_i915_private *dev_priv = dev->dev_private;
2423
	struct intel_ring_buffer *ring;
2549
	struct intel_ring_buffer *ring;
2424
	u32 rp_state_cap;
2550
	u32 rp_state_cap;
2425
	u32 gt_perf_status;
2551
	u32 gt_perf_status;
2426
	u32 pcu_mbox, rc6_mask = 0;
2552
	u32 rc6vids, pcu_mbox, rc6_mask = 0;
2427
	u32 gtfifodbg;
2553
	u32 gtfifodbg;
2428
	int rc6_mode;
2554
	int rc6_mode;
2429
	int i;
2555
	int i, ret;
Line 2430... Line 2556...
2430
 
2556
 
Line 2431... Line 2557...
2431
	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
2557
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
2432
 
2558
 
2433
	/* Here begins a magic sequence of register writes to enable
2559
	/* Here begins a magic sequence of register writes to enable
2434
	 * auto-downclocking.
2560
	 * auto-downclocking.
Line 2520... Line 2646...
2520
		   GEN6_RP_MEDIA_IS_GFX |
2646
		   GEN6_RP_MEDIA_IS_GFX |
2521
		   GEN6_RP_ENABLE |
2647
		   GEN6_RP_ENABLE |
2522
		   GEN6_RP_UP_BUSY_AVG |
2648
		   GEN6_RP_UP_BUSY_AVG |
2523
		   (IS_HASWELL(dev) ? GEN7_RP_DOWN_IDLE_AVG : GEN6_RP_DOWN_IDLE_CONT));
2649
		   (IS_HASWELL(dev) ? GEN7_RP_DOWN_IDLE_AVG : GEN6_RP_DOWN_IDLE_CONT));
Line 2524... Line -...
2524
 
-
 
2525
	if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
-
 
2526
		     500))
-
 
2527
		DRM_ERROR("timeout waiting for pcode mailbox to become idle\n");
-
 
2528
 
-
 
2529
	I915_WRITE(GEN6_PCODE_DATA, 0);
-
 
2530
	I915_WRITE(GEN6_PCODE_MAILBOX,
-
 
2531
		   GEN6_PCODE_READY |
2650
 
2532
		   GEN6_PCODE_WRITE_MIN_FREQ_TABLE);
-
 
2533
	if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
2651
	ret = sandybridge_pcode_write(dev_priv, GEN6_PCODE_WRITE_MIN_FREQ_TABLE, 0);
2534
		     500))
-
 
2535
		DRM_ERROR("timeout waiting for pcode mailbox to finish\n");
-
 
2536
 
-
 
2537
	/* Check for overclock support */
-
 
2538
	if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
2652
	if (!ret) {
2539
		     500))
-
 
2540
		DRM_ERROR("timeout waiting for pcode mailbox to become idle\n");
2653
		pcu_mbox = 0;
2541
	I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_READ_OC_PARAMS);
-
 
2542
	pcu_mbox = I915_READ(GEN6_PCODE_DATA);
-
 
2543
	if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
-
 
2544
		     500))
-
 
2545
		DRM_ERROR("timeout waiting for pcode mailbox to finish\n");
2654
		ret = sandybridge_pcode_read(dev_priv, GEN6_READ_OC_PARAMS, &pcu_mbox);
2546
	if (pcu_mbox & (1<<31)) { /* OC supported */
2655
		if (ret && pcu_mbox & (1<<31)) { /* OC supported */
2547
		dev_priv->rps.max_delay = pcu_mbox & 0xff;
2656
		dev_priv->rps.max_delay = pcu_mbox & 0xff;
2548
		DRM_DEBUG_DRIVER("overclocking supported, adjusting frequency max to %dMHz\n", pcu_mbox * 50);
2657
		DRM_DEBUG_DRIVER("overclocking supported, adjusting frequency max to %dMHz\n", pcu_mbox * 50);
-
 
2658
	}
-
 
2659
	} else {
-
 
2660
		DRM_DEBUG_DRIVER("Failed to set the min frequency\n");
Line 2549... Line 2661...
2549
	}
2661
	}
Line 2550... Line 2662...
2550
 
2662
 
2551
	gen6_set_rps(dev_priv->dev, (gt_perf_status & 0xff00) >> 8);
2663
	gen6_set_rps(dev_priv->dev, (gt_perf_status & 0xff00) >> 8);
Line 2557... Line 2669...
2557
	I915_WRITE(GEN6_PMIMR, 0);
2669
	I915_WRITE(GEN6_PMIMR, 0);
2558
	spin_unlock_irq(&dev_priv->rps.lock);
2670
	spin_unlock_irq(&dev_priv->rps.lock);
2559
	/* enable all PM interrupts */
2671
	/* enable all PM interrupts */
2560
	I915_WRITE(GEN6_PMINTRMSK, 0);
2672
	I915_WRITE(GEN6_PMINTRMSK, 0);
Line -... Line 2673...
-
 
2673
 
-
 
2674
	rc6vids = 0;
-
 
2675
	ret = sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
-
 
2676
	if (IS_GEN6(dev) && ret) {
-
 
2677
		DRM_DEBUG_DRIVER("Couldn't check for BIOS workaround\n");
-
 
2678
	} else if (IS_GEN6(dev) && (GEN6_DECODE_RC6_VID(rc6vids & 0xff) < 450)) {
-
 
2679
		DRM_DEBUG_DRIVER("You should update your BIOS. Correcting minimum rc6 voltage (%dmV->%dmV)\n",
-
 
2680
			  GEN6_DECODE_RC6_VID(rc6vids & 0xff), 450);
-
 
2681
		rc6vids &= 0xffff00;
-
 
2682
		rc6vids |= GEN6_ENCODE_RC6_VID(450);
-
 
2683
		ret = sandybridge_pcode_write(dev_priv, GEN6_PCODE_WRITE_RC6VIDS, rc6vids);
-
 
2684
		if (ret)
-
 
2685
			DRM_ERROR("Couldn't fix incorrect rc6 voltage\n");
-
 
2686
	}
2561
 
2687
 
2562
	gen6_gt_force_wake_put(dev_priv);
2688
	gen6_gt_force_wake_put(dev_priv);
Line 2563... Line 2689...
2563
}
2689
}
2564
 
2690
 
2565
#if 0
2691
#if 0
2566
static void gen6_update_ring_freq(struct drm_device *dev)
2692
static void gen6_update_ring_freq(struct drm_device *dev)
2567
{
2693
{
-
 
2694
	struct drm_i915_private *dev_priv = dev->dev_private;
2568
	struct drm_i915_private *dev_priv = dev->dev_private;
2695
	int min_freq = 15;
2569
	int min_freq = 15;
2696
	int gpu_freq;
Line 2570... Line 2697...
2570
	int gpu_freq, ia_freq, max_ia_freq;
2697
	unsigned int ia_freq, max_ia_freq;
Line 2571... Line 2698...
2571
	int scaling_factor = 180;
2698
	int scaling_factor = 180;
2572
 
2699
 
2573
	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
2700
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
2574
 
2701
 
Line 2599... Line 2726...
2599
		if (gpu_freq < min_freq)
2726
		if (gpu_freq < min_freq)
2600
			ia_freq = 800;
2727
			ia_freq = 800;
2601
		else
2728
		else
2602
			ia_freq = max_ia_freq - ((diff * scaling_factor) / 2);
2729
			ia_freq = max_ia_freq - ((diff * scaling_factor) / 2);
2603
		ia_freq = DIV_ROUND_CLOSEST(ia_freq, 100);
2730
		ia_freq = DIV_ROUND_CLOSEST(ia_freq, 100);
-
 
2731
		ia_freq <<= GEN6_PCODE_FREQ_IA_RATIO_SHIFT;
Line 2604... Line 2732...
2604
 
2732
 
2605
		I915_WRITE(GEN6_PCODE_DATA,
-
 
2606
			   (ia_freq << GEN6_PCODE_FREQ_IA_RATIO_SHIFT) |
-
 
2607
			   gpu_freq);
-
 
2608
		I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY |
2733
		sandybridge_pcode_write(dev_priv,
2609
			   GEN6_PCODE_WRITE_MIN_FREQ_TABLE);
-
 
2610
		if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) &
-
 
2611
			      GEN6_PCODE_READY) == 0, 10)) {
-
 
2612
			DRM_ERROR("pcode write of freq table timed out\n");
2734
					GEN6_PCODE_WRITE_MIN_FREQ_TABLE,
2613
			continue;
-
 
2614
		}
2735
					ia_freq | gpu_freq);
2615
	}
2736
	}
2616
}
2737
}
Line 2617... Line 2738...
2617
#endif
2738
#endif
2618
 
2739
 
2619
void ironlake_teardown_rc6(struct drm_device *dev)
2740
void ironlake_teardown_rc6(struct drm_device *dev)
Line 2620... Line 2741...
2620
{
2741
{
2621
	struct drm_i915_private *dev_priv = dev->dev_private;
2742
	struct drm_i915_private *dev_priv = dev->dev_private;
2622
 
2743
 
2623
	if (dev_priv->renderctx) {
2744
	if (dev_priv->ips.renderctx) {
2624
		i915_gem_object_unpin(dev_priv->renderctx);
2745
		i915_gem_object_unpin(dev_priv->ips.renderctx);
Line 2625... Line 2746...
2625
		drm_gem_object_unreference(&dev_priv->renderctx->base);
2746
		drm_gem_object_unreference(&dev_priv->ips.renderctx->base);
2626
		dev_priv->renderctx = NULL;
2747
		dev_priv->ips.renderctx = NULL;
2627
	}
2748
	}
2628
 
2749
 
2629
	if (dev_priv->pwrctx) {
2750
	if (dev_priv->ips.pwrctx) {
2630
		i915_gem_object_unpin(dev_priv->pwrctx);
2751
		i915_gem_object_unpin(dev_priv->ips.pwrctx);
Line 2631... Line 2752...
2631
		drm_gem_object_unreference(&dev_priv->pwrctx->base);
2752
		drm_gem_object_unreference(&dev_priv->ips.pwrctx->base);
2632
		dev_priv->pwrctx = NULL;
2753
		dev_priv->ips.pwrctx = NULL;
Line 2653... Line 2774...
2653
 
2774
 
2654
static int ironlake_setup_rc6(struct drm_device *dev)
2775
static int ironlake_setup_rc6(struct drm_device *dev)
2655
{
2776
{
Line 2656... Line 2777...
2656
	struct drm_i915_private *dev_priv = dev->dev_private;
2777
	struct drm_i915_private *dev_priv = dev->dev_private;
2657
 
2778
 
2658
	if (dev_priv->renderctx == NULL)
2779
	if (dev_priv->ips.renderctx == NULL)
2659
		dev_priv->renderctx = intel_alloc_context_page(dev);
2780
		dev_priv->ips.renderctx = intel_alloc_context_page(dev);
Line 2660... Line 2781...
2660
	if (!dev_priv->renderctx)
2781
	if (!dev_priv->ips.renderctx)
2661
		return -ENOMEM;
2782
		return -ENOMEM;
2662
 
2783
 
2663
	if (dev_priv->pwrctx == NULL)
2784
	if (dev_priv->ips.pwrctx == NULL)
2664
		dev_priv->pwrctx = intel_alloc_context_page(dev);
2785
		dev_priv->ips.pwrctx = intel_alloc_context_page(dev);
2665
	if (!dev_priv->pwrctx) {
2786
	if (!dev_priv->ips.pwrctx) {
Line 2666... Line 2787...
2666
		ironlake_teardown_rc6(dev);
2787
		ironlake_teardown_rc6(dev);
Line 2672... Line 2793...
2672
 
2793
 
2673
static void ironlake_enable_rc6(struct drm_device *dev)
2794
static void ironlake_enable_rc6(struct drm_device *dev)
2674
{
2795
{
2675
	struct drm_i915_private *dev_priv = dev->dev_private;
2796
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2797
	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
2676
	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
2798
	bool was_interruptible;
Line 2677... Line 2799...
2677
	int ret;
2799
	int ret;
2678
 
2800
 
2679
	/* rc6 disabled by default due to repeated reports of hanging during
2801
	/* rc6 disabled by default due to repeated reports of hanging during
Line 2686... Line 2808...
2686
 
2808
 
2687
	ret = ironlake_setup_rc6(dev);
2809
	ret = ironlake_setup_rc6(dev);
2688
	if (ret)
2810
	if (ret)
Line -... Line 2811...
-
 
2811
		return;
-
 
2812
 
-
 
2813
	was_interruptible = dev_priv->mm.interruptible;
2689
		return;
2814
	dev_priv->mm.interruptible = false;
2690
 
2815
 
2691
	/*
2816
	/*
2692
	 * GPU can automatically power down the render unit if given a page
2817
	 * GPU can automatically power down the render unit if given a page
2693
	 * to save state.
2818
	 * to save state.
2694
	 */
2819
	 */
2695
	ret = intel_ring_begin(ring, 6);
2820
	ret = intel_ring_begin(ring, 6);
-
 
2821
	if (ret) {
2696
	if (ret) {
2822
		ironlake_teardown_rc6(dev);
2697
		ironlake_teardown_rc6(dev);
2823
		dev_priv->mm.interruptible = was_interruptible;
Line 2698... Line 2824...
2698
		return;
2824
		return;
2699
	}
2825
	}
2700
 
2826
 
2701
	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
2827
	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
2702
	intel_ring_emit(ring, MI_SET_CONTEXT);
2828
	intel_ring_emit(ring, MI_SET_CONTEXT);
2703
	intel_ring_emit(ring, dev_priv->renderctx->gtt_offset |
2829
	intel_ring_emit(ring, dev_priv->ips.renderctx->gtt_offset |
2704
			MI_MM_SPACE_GTT |
2830
			MI_MM_SPACE_GTT |
2705
			MI_SAVE_EXT_STATE_EN |
2831
			MI_SAVE_EXT_STATE_EN |
Line 2713... Line 2839...
2713
	/*
2839
	/*
2714
	 * Wait for the command parser to advance past MI_SET_CONTEXT. The HW
2840
	 * Wait for the command parser to advance past MI_SET_CONTEXT. The HW
2715
	 * does an implicit flush, combined with MI_FLUSH above, it should be
2841
	 * does an implicit flush, combined with MI_FLUSH above, it should be
2716
	 * safe to assume that renderctx is valid
2842
	 * safe to assume that renderctx is valid
2717
	 */
2843
	 */
2718
	ret = intel_wait_ring_idle(ring);
2844
	ret = intel_ring_idle(ring);
-
 
2845
	dev_priv->mm.interruptible = was_interruptible;
2719
	if (ret) {
2846
	if (ret) {
2720
		DRM_ERROR("failed to enable ironlake power power savings\n");
2847
		DRM_ERROR("failed to enable ironlake power power savings\n");
2721
		ironlake_teardown_rc6(dev);
2848
		ironlake_teardown_rc6(dev);
2722
		return;
2849
		return;
2723
	}
2850
	}
Line 2724... Line 2851...
2724
 
2851
 
2725
	I915_WRITE(PWRCTXA, dev_priv->pwrctx->gtt_offset | PWRCTX_EN);
2852
	I915_WRITE(PWRCTXA, dev_priv->ips.pwrctx->gtt_offset | PWRCTX_EN);
2726
	I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
2853
	I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
Line 2727... Line 2854...
2727
}
2854
}
2728
 
2855
 
Line 3329... Line 3456...
3329
	dev_priv->ips.corr = (lcfuse & LCFUSE_HIV_MASK);
3456
	dev_priv->ips.corr = (lcfuse & LCFUSE_HIV_MASK);
3330
}
3457
}
Line 3331... Line 3458...
3331
 
3458
 
3332
void intel_disable_gt_powersave(struct drm_device *dev)
3459
void intel_disable_gt_powersave(struct drm_device *dev)
-
 
3460
{
-
 
3461
	struct drm_i915_private *dev_priv = dev->dev_private;
3333
{
3462
 
3334
	if (IS_IRONLAKE_M(dev)) {
3463
	if (IS_IRONLAKE_M(dev)) {
3335
		ironlake_disable_drps(dev);
3464
		ironlake_disable_drps(dev);
3336
		ironlake_disable_rc6(dev);
3465
		ironlake_disable_rc6(dev);
3337
	} else if (INTEL_INFO(dev)->gen >= 6 && !IS_VALLEYVIEW(dev)) {
3466
	} else if (INTEL_INFO(dev)->gen >= 6 && !IS_VALLEYVIEW(dev)) {
3338
		gen6_disable_rps(dev);
3467
		gen6_disable_rps(dev);
3339
	}
3468
	}
Line 3340... Line 3469...
3340
}
3469
}
3341
 
3470
 
-
 
3471
void intel_enable_gt_powersave(struct drm_device *dev)
-
 
3472
{
3342
void intel_enable_gt_powersave(struct drm_device *dev)
3473
	struct drm_i915_private *dev_priv = dev->dev_private;
3343
{
3474
 
3344
	if (IS_IRONLAKE_M(dev)) {
3475
	if (IS_IRONLAKE_M(dev)) {
3345
		ironlake_enable_drps(dev);
3476
		ironlake_enable_drps(dev);
3346
		ironlake_enable_rc6(dev);
3477
		ironlake_enable_rc6(dev);
-
 
3478
		intel_init_emon(dev);
-
 
3479
	} else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) {
-
 
3480
		/*
3347
		intel_init_emon(dev);
3481
		 * PCU communication is slow and this doesn't need to be
-
 
3482
		 * done at any specific time, so do this out of our fast path
-
 
3483
		 * to make resume and init faster.
3348
	} else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) {
3484
		 */
3349
//       gen6_enable_rps(dev);
3485
//		schedule_delayed_work(&dev_priv->rps.delayed_resume_work,
3350
//       gen6_update_ring_freq(dev);
3486
//				      round_jiffies_up_relative(HZ));
Line -... Line 3487...
-
 
3487
	}
-
 
3488
}
-
 
3489
 
-
 
3490
static void ibx_init_clock_gating(struct drm_device *dev)
-
 
3491
{
-
 
3492
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3493
 
-
 
3494
	/*
-
 
3495
	 * On Ibex Peak and Cougar Point, we need to disable clock
-
 
3496
	 * gating for the panel power sequencer or it will fail to
-
 
3497
	 * start up when no ports are active.
-
 
3498
	 */
3351
	}
3499
	I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
3352
}
3500
}
3353
 
3501
 
3354
static void ironlake_init_clock_gating(struct drm_device *dev)
3502
static void ironlake_init_clock_gating(struct drm_device *dev)
Line 3355... Line 3503...
3355
{
3503
{
3356
	struct drm_i915_private *dev_priv = dev->dev_private;
3504
	struct drm_i915_private *dev_priv = dev->dev_private;
3357
	uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
3505
	uint32_t dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
3358
 
3506
 
3359
	/* Required for FBC */
-
 
3360
	dspclk_gate |= DPFCUNIT_CLOCK_GATE_DISABLE |
-
 
Line 3361... Line 3507...
3361
		DPFCRUNIT_CLOCK_GATE_DISABLE |
3507
	/* Required for FBC */
3362
		DPFDUNIT_CLOCK_GATE_DISABLE;
3508
	dspclk_gate |= ILK_DPFCRUNIT_CLOCK_GATE_DISABLE |
3363
	/* Required for CxSR */
3509
		   ILK_DPFCUNIT_CLOCK_GATE_DISABLE |
3364
	dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE;
3510
		   ILK_DPFDUNIT_CLOCK_GATE_ENABLE;
3365
 
3511
 
Line 3366... Line -...
3366
	I915_WRITE(PCH_3DCGDIS0,
-
 
3367
		   MARIUNIT_CLOCK_GATE_DISABLE |
-
 
3368
		   SVSMUNIT_CLOCK_GATE_DISABLE);
3512
	I915_WRITE(PCH_3DCGDIS0,
3369
	I915_WRITE(PCH_3DCGDIS1,
3513
		   MARIUNIT_CLOCK_GATE_DISABLE |
3370
		   VFMUNIT_CLOCK_GATE_DISABLE);
3514
		   SVSMUNIT_CLOCK_GATE_DISABLE);
3371
 
3515
	I915_WRITE(PCH_3DCGDIS1,
3372
	I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
3516
		   VFMUNIT_CLOCK_GATE_DISABLE);
3373
 
3517
 
3374
	/*
3518
	/*
3375
	 * According to the spec the following bits should be set in
3519
	 * According to the spec the following bits should be set in
3376
	 * order to enable memory self-refresh
3520
	 * order to enable memory self-refresh
3377
	 * The bit 22/21 of 0x42004
3521
	 * The bit 22/21 of 0x42004
3378
	 * The bit 5 of 0x42020
-
 
3379
	 * The bit 15 of 0x45000
-
 
3380
	 */
3522
	 * The bit 5 of 0x42020
3381
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3523
	 * The bit 15 of 0x45000
3382
		   (I915_READ(ILK_DISPLAY_CHICKEN2) |
3524
	 */
3383
		    ILK_DPARB_GATE | ILK_VSDPFD_FULL));
3525
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3384
	I915_WRITE(ILK_DSPCLK_GATE,
3526
		   (I915_READ(ILK_DISPLAY_CHICKEN2) |
3385
		   (I915_READ(ILK_DSPCLK_GATE) |
3527
		    ILK_DPARB_GATE | ILK_VSDPFD_FULL));
Line 3403... Line 3545...
3403
			   I915_READ(ILK_DISPLAY_CHICKEN1) |
3545
			   I915_READ(ILK_DISPLAY_CHICKEN1) |
3404
			   ILK_FBCQ_DIS);
3546
			   ILK_FBCQ_DIS);
3405
		I915_WRITE(ILK_DISPLAY_CHICKEN2,
3547
		I915_WRITE(ILK_DISPLAY_CHICKEN2,
3406
			   I915_READ(ILK_DISPLAY_CHICKEN2) |
3548
			   I915_READ(ILK_DISPLAY_CHICKEN2) |
3407
			   ILK_DPARB_GATE);
3549
			   ILK_DPARB_GATE);
3408
		I915_WRITE(ILK_DSPCLK_GATE,
-
 
3409
			   I915_READ(ILK_DSPCLK_GATE) |
-
 
3410
			   ILK_DPFC_DIS1 |
-
 
3411
			   ILK_DPFC_DIS2 |
-
 
3412
			   ILK_CLK_FBC);
-
 
3413
	}
3550
	}
Line -... Line 3551...
-
 
3551
 
-
 
3552
	I915_WRITE(ILK_DSPCLK_GATE_D, dspclk_gate);
3414
 
3553
 
3415
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3554
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3416
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
3555
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
3417
		   ILK_ELPIN_409_SELECT);
3556
		   ILK_ELPIN_409_SELECT);
3418
	I915_WRITE(_3D_CHICKEN2,
3557
	I915_WRITE(_3D_CHICKEN2,
3419
		   _3D_CHICKEN2_WM_READ_PIPELINED << 16 |
3558
		   _3D_CHICKEN2_WM_READ_PIPELINED << 16 |
-
 
3559
		   _3D_CHICKEN2_WM_READ_PIPELINED);
-
 
3560
 
-
 
3561
	/* WaDisableRenderCachePipelinedFlush */
-
 
3562
	I915_WRITE(CACHE_MODE_0,
-
 
3563
		   _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
-
 
3564
 
-
 
3565
	ibx_init_clock_gating(dev);
-
 
3566
}
-
 
3567
 
-
 
3568
static void cpt_init_clock_gating(struct drm_device *dev)
-
 
3569
{
-
 
3570
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3571
	int pipe;
-
 
3572
 
-
 
3573
	/*
-
 
3574
	 * On Ibex Peak and Cougar Point, we need to disable clock
-
 
3575
	 * gating for the panel power sequencer or it will fail to
-
 
3576
	 * start up when no ports are active.
-
 
3577
	 */
-
 
3578
	I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
-
 
3579
	I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) |
-
 
3580
		   DPLS_EDP_PPS_FIX_DIS);
-
 
3581
	/* The below fixes the weird display corruption, a few pixels shifted
-
 
3582
	 * downward, on (only) LVDS of some HP laptops with IVY.
-
 
3583
	 */
-
 
3584
	for_each_pipe(pipe)
-
 
3585
		I915_WRITE(TRANS_CHICKEN2(pipe), TRANS_CHICKEN2_TIMING_OVERRIDE);
-
 
3586
	/* WADP0ClockGatingDisable */
-
 
3587
	for_each_pipe(pipe) {
-
 
3588
		I915_WRITE(TRANS_CHICKEN1(pipe),
-
 
3589
			   TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
3420
		   _3D_CHICKEN2_WM_READ_PIPELINED);
3590
	}
Line 3421... Line 3591...
3421
}
3591
}
3422
 
3592
 
3423
static void gen6_init_clock_gating(struct drm_device *dev)
3593
static void gen6_init_clock_gating(struct drm_device *dev)
3424
{
3594
{
3425
	struct drm_i915_private *dev_priv = dev->dev_private;
3595
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 3426... Line 3596...
3426
	int pipe;
3596
	int pipe;
Line 3427... Line 3597...
3427
	uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
3597
	uint32_t dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
3428
 
3598
 
3429
	I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
3599
	I915_WRITE(ILK_DSPCLK_GATE_D, dspclk_gate);
Line -... Line 3600...
-
 
3600
 
-
 
3601
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
-
 
3602
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
-
 
3603
		   ILK_ELPIN_409_SELECT);
-
 
3604
 
-
 
3605
	/* WaDisableHiZPlanesWhenMSAAEnabled */
-
 
3606
	I915_WRITE(_3D_CHICKEN,
-
 
3607
		   _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB));
-
 
3608
 
3430
 
3609
	/* WaSetupGtModeTdRowDispatch */
3431
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3610
	if (IS_SNB_GT1(dev))
3432
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
3611
		I915_WRITE(GEN6_GT_MODE,
Line 3433... Line 3612...
3433
		   ILK_ELPIN_409_SELECT);
3612
			   _MASKED_BIT_ENABLE(GEN6_TD_FOUR_ROW_DISPATCH_DISABLE));
Line 3479... Line 3658...
3479
		   I915_READ(ILK_DISPLAY_CHICKEN1) |
3658
		   I915_READ(ILK_DISPLAY_CHICKEN1) |
3480
		   ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS);
3659
		   ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS);
3481
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3660
	I915_WRITE(ILK_DISPLAY_CHICKEN2,
3482
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
3661
		   I915_READ(ILK_DISPLAY_CHICKEN2) |
3483
		   ILK_DPARB_GATE | ILK_VSDPFD_FULL);
3662
		   ILK_DPARB_GATE | ILK_VSDPFD_FULL);
3484
	I915_WRITE(ILK_DSPCLK_GATE,
3663
	I915_WRITE(ILK_DSPCLK_GATE_D,
3485
		   I915_READ(ILK_DSPCLK_GATE) |
3664
		   I915_READ(ILK_DSPCLK_GATE_D) |
3486
		   ILK_DPARB_CLK_GATE  |
3665
		   ILK_DPARBUNIT_CLOCK_GATE_ENABLE  |
3487
		   ILK_DPFD_CLK_GATE);
3666
		   ILK_DPFDUNIT_CLOCK_GATE_ENABLE);
Line -... Line 3667...
-
 
3667
 
3488
 
3668
	/* WaMbcDriverBootEnable */
3489
	I915_WRITE(GEN6_MBCTL, I915_READ(GEN6_MBCTL) |
3669
	I915_WRITE(GEN6_MBCTL, I915_READ(GEN6_MBCTL) |
Line 3490... Line 3670...
3490
		   GEN6_MBCTL_ENABLE_BOOT_FETCH);
3670
		   GEN6_MBCTL_ENABLE_BOOT_FETCH);
3491
 
3671
 
Line 3498... Line 3678...
3498
 
3678
 
3499
	/* The default value should be 0x200 according to docs, but the two
3679
	/* The default value should be 0x200 according to docs, but the two
3500
	 * platforms I checked have a 0 for this. (Maybe BIOS overrides?) */
3680
	 * platforms I checked have a 0 for this. (Maybe BIOS overrides?) */
3501
	I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_DISABLE(0xffff));
3681
	I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_DISABLE(0xffff));
-
 
3682
	I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_ENABLE(GEN6_GT_MODE_HI));
-
 
3683
 
3502
	I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_ENABLE(GEN6_GT_MODE_HI));
3684
	cpt_init_clock_gating(dev);
Line 3503... Line 3685...
3503
}
3685
}
3504
 
3686
 
3505
static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
3687
static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
Line 3512... Line 3694...
3512
	reg |= GEN7_FF_DS_SCHED_HW;
3694
	reg |= GEN7_FF_DS_SCHED_HW;
Line 3513... Line 3695...
3513
 
3695
 
3514
	I915_WRITE(GEN7_FF_THREAD_MODE, reg);
3696
	I915_WRITE(GEN7_FF_THREAD_MODE, reg);
Line -... Line 3697...
-
 
3697
}
-
 
3698
 
-
 
3699
static void lpt_init_clock_gating(struct drm_device *dev)
-
 
3700
{
-
 
3701
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3702
 
-
 
3703
	/*
-
 
3704
	 * TODO: this bit should only be enabled when really needed, then
-
 
3705
	 * disabled when not needed anymore in order to save power.
-
 
3706
	 */
-
 
3707
	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE)
-
 
3708
		I915_WRITE(SOUTH_DSPCLK_GATE_D,
-
 
3709
			   I915_READ(SOUTH_DSPCLK_GATE_D) |
-
 
3710
			   PCH_LP_PARTITION_LEVEL_DISABLE);
3515
}
3711
}
3516
 
3712
 
3517
static void haswell_init_clock_gating(struct drm_device *dev)
3713
static void haswell_init_clock_gating(struct drm_device *dev)
3518
{
3714
{
3519
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3520
	int pipe;
-
 
3521
	uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
-
 
Line 3522... Line 3715...
3522
 
3715
	struct drm_i915_private *dev_priv = dev->dev_private;
3523
	I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
3716
	int pipe;
3524
 
3717
 
Line 3525... Line 3718...
3525
	I915_WRITE(WM3_LP_ILK, 0);
3718
	I915_WRITE(WM3_LP_ILK, 0);
3526
	I915_WRITE(WM2_LP_ILK, 0);
3719
	I915_WRITE(WM2_LP_ILK, 0);
3527
	I915_WRITE(WM1_LP_ILK, 0);
3720
	I915_WRITE(WM1_LP_ILK, 0);
3528
 
3721
 
Line 3529... Line -...
3529
	/* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
-
 
3530
	 * This implements the WaDisableRCZUnitClockGating workaround.
-
 
3531
	 */
-
 
3532
	I915_WRITE(GEN6_UCGCTL2, GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
-
 
3533
 
-
 
3534
	I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE);
-
 
3535
 
3722
	/* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
3536
	I915_WRITE(IVB_CHICKEN3,
3723
	 * This implements the WaDisableRCZUnitClockGating workaround.
3537
		   CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
3724
	 */
Line 3538... Line 3725...
3538
		   CHICKEN3_DGMG_DONE_FIX_DISABLE);
3725
	I915_WRITE(GEN6_UCGCTL2, GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
Line 3563... Line 3750...
3563
 
3750
 
3564
	/* WaDisable4x2SubspanOptimization */
3751
	/* WaDisable4x2SubspanOptimization */
3565
	I915_WRITE(CACHE_MODE_1,
3752
	I915_WRITE(CACHE_MODE_1,
Line -... Line 3753...
-
 
3753
		   _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
-
 
3754
 
-
 
3755
	/* WaMbcDriverBootEnable */
-
 
3756
	I915_WRITE(GEN6_MBCTL, I915_READ(GEN6_MBCTL) |
3566
		   _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
3757
		   GEN6_MBCTL_ENABLE_BOOT_FETCH);
3567
 
3758
 
3568
	/* XXX: This is a workaround for early silicon revisions and should be
3759
	/* XXX: This is a workaround for early silicon revisions and should be
3569
	 * removed later.
3760
	 * removed later.
3570
	 */
3761
	 */
3571
	I915_WRITE(WM_DBG,
3762
	I915_WRITE(WM_DBG,
3572
			I915_READ(WM_DBG) |
3763
			I915_READ(WM_DBG) |
3573
			WM_DBG_DISALLOW_MULTIPLE_LP |
3764
			WM_DBG_DISALLOW_MULTIPLE_LP |
Line -... Line 3765...
-
 
3765
			WM_DBG_DISALLOW_SPRITE |
3574
			WM_DBG_DISALLOW_SPRITE |
3766
			WM_DBG_DISALLOW_MAXFIFO);
Line 3575... Line 3767...
3575
			WM_DBG_DISALLOW_MAXFIFO);
3767
 
3576
 
3768
	lpt_init_clock_gating(dev);
3577
}
3769
}
3578
 
3770
 
3579
static void ivybridge_init_clock_gating(struct drm_device *dev)
-
 
3580
{
3771
static void ivybridge_init_clock_gating(struct drm_device *dev)
Line 3581... Line -...
3581
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3582
	int pipe;
-
 
3583
	uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
3772
{
3584
	uint32_t snpcr;
3773
	struct drm_i915_private *dev_priv = dev->dev_private;
3585
 
3774
	int pipe;
Line 3586... Line 3775...
3586
	I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
3775
	uint32_t snpcr;
Line -... Line 3776...
-
 
3776
 
-
 
3777
	I915_WRITE(WM3_LP_ILK, 0);
-
 
3778
	I915_WRITE(WM2_LP_ILK, 0);
-
 
3779
	I915_WRITE(WM1_LP_ILK, 0);
-
 
3780
 
3587
 
3781
	I915_WRITE(ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
3588
	I915_WRITE(WM3_LP_ILK, 0);
3782
 
3589
	I915_WRITE(WM2_LP_ILK, 0);
3783
	/* WaDisableEarlyCull */
Line -... Line 3784...
-
 
3784
	I915_WRITE(_3D_CHICKEN3,
-
 
3785
		   _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
-
 
3786
 
-
 
3787
	/* WaDisableBackToBackFlipFix */
-
 
3788
	I915_WRITE(IVB_CHICKEN3,
-
 
3789
		   CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
-
 
3790
		   CHICKEN3_DGMG_DONE_FIX_DISABLE);
-
 
3791
 
3590
	I915_WRITE(WM1_LP_ILK, 0);
3792
	/* WaDisablePSDDualDispatchEnable */
3591
 
3793
	if (IS_IVB_GT1(dev))
3592
	I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE);
3794
		I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
Line 3593... Line 3795...
3593
 
3795
			   _MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
3594
	I915_WRITE(IVB_CHICKEN3,
3796
	else
3595
		   CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
3797
		I915_WRITE(GEN7_HALF_SLICE_CHICKEN1_GT2,
3596
		   CHICKEN3_DGMG_DONE_FIX_DISABLE);
3798
			   _MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
3597
 
3799
 
-
 
3800
	/* Apply the WaDisableRHWOOptimizationForRenderHang workaround. */
-
 
3801
	I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
-
 
3802
		   GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
-
 
3803
 
-
 
3804
	/* WaApplyL3ControlAndL3ChickenMode requires those two on Ivy Bridge */
-
 
3805
	I915_WRITE(GEN7_L3CNTLREG1,
-
 
3806
			GEN7_WA_FOR_GEN7_L3_CONTROL);
-
 
3807
	I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER,
-
 
3808
			GEN7_WA_L3_CHICKEN_MODE);
-
 
3809
	if (IS_IVB_GT1(dev))
-
 
3810
		I915_WRITE(GEN7_ROW_CHICKEN2,
Line 3598... Line 3811...
3598
	/* Apply the WaDisableRHWOOptimizationForRenderHang workaround. */
3811
			   _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
3599
	I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
3812
	else
3600
		   GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
3813
		I915_WRITE(GEN7_ROW_CHICKEN2_GT2,
3601
 
3814
			   _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
Line 3632... Line 3845...
3632
			   I915_READ(DSPCNTR(pipe)) |
3845
			   I915_READ(DSPCNTR(pipe)) |
3633
			   DISPPLANE_TRICKLE_FEED_DISABLE);
3846
			   DISPPLANE_TRICKLE_FEED_DISABLE);
3634
		intel_flush_display_plane(dev_priv, pipe);
3847
		intel_flush_display_plane(dev_priv, pipe);
3635
	}
3848
	}
Line -... Line 3849...
-
 
3849
 
3636
 
3850
	/* WaMbcDriverBootEnable */
3637
	I915_WRITE(GEN6_MBCTL, I915_READ(GEN6_MBCTL) |
3851
	I915_WRITE(GEN6_MBCTL, I915_READ(GEN6_MBCTL) |
Line 3638... Line 3852...
3638
		   GEN6_MBCTL_ENABLE_BOOT_FETCH);
3852
		   GEN6_MBCTL_ENABLE_BOOT_FETCH);
Line 3645... Line 3859...
3645
 
3859
 
3646
	snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
3860
	snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
3647
	snpcr &= ~GEN6_MBC_SNPCR_MASK;
3861
	snpcr &= ~GEN6_MBC_SNPCR_MASK;
3648
	snpcr |= GEN6_MBC_SNPCR_MED;
3862
	snpcr |= GEN6_MBC_SNPCR_MED;
-
 
3863
	I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
-
 
3864
 
3649
	I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
3865
	cpt_init_clock_gating(dev);
Line 3650... Line 3866...
3650
}
3866
}
3651
 
3867
 
3652
static void valleyview_init_clock_gating(struct drm_device *dev)
3868
static void valleyview_init_clock_gating(struct drm_device *dev)
3653
{
3869
{
3654
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3655
	int pipe;
-
 
3656
	uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
-
 
Line 3657... Line 3870...
3657
 
3870
	struct drm_i915_private *dev_priv = dev->dev_private;
3658
	I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
3871
	int pipe;
3659
 
3872
 
Line 3660... Line 3873...
3660
	I915_WRITE(WM3_LP_ILK, 0);
3873
	I915_WRITE(WM3_LP_ILK, 0);
Line -... Line 3874...
-
 
3874
	I915_WRITE(WM2_LP_ILK, 0);
-
 
3875
	I915_WRITE(WM1_LP_ILK, 0);
-
 
3876
 
-
 
3877
	I915_WRITE(ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
-
 
3878
 
3661
	I915_WRITE(WM2_LP_ILK, 0);
3879
	/* WaDisableEarlyCull */
3662
	I915_WRITE(WM1_LP_ILK, 0);
3880
	I915_WRITE(_3D_CHICKEN3,
3663
 
3881
		   _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
Line -... Line 3882...
-
 
3882
 
-
 
3883
	/* WaDisableBackToBackFlipFix */
-
 
3884
	I915_WRITE(IVB_CHICKEN3,
3664
	I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE);
3885
		   CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
3665
 
3886
		   CHICKEN3_DGMG_DONE_FIX_DISABLE);
3666
	I915_WRITE(IVB_CHICKEN3,
3887
 
Line 3667... Line 3888...
3667
		   CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
3888
	I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
3668
		   CHICKEN3_DGMG_DONE_FIX_DISABLE);
3889
		   _MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
3669
 
3890
 
Line -... Line 3891...
-
 
3891
	/* Apply the WaDisableRHWOOptimizationForRenderHang workaround. */
-
 
3892
	I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
-
 
3893
		   GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
-
 
3894
 
-
 
3895
	/* WaApplyL3ControlAndL3ChickenMode requires those two on Ivy Bridge */
-
 
3896
	I915_WRITE(GEN7_L3CNTLREG1, I915_READ(GEN7_L3CNTLREG1) | GEN7_L3AGDIS);
-
 
3897
	I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER, GEN7_WA_L3_CHICKEN_MODE);
-
 
3898
 
-
 
3899
	/* WaForceL3Serialization */
-
 
3900
	I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
-
 
3901
		   ~L3SQ_URB_READ_CAM_MATCH_DISABLE);
-
 
3902
 
3670
	/* Apply the WaDisableRHWOOptimizationForRenderHang workaround. */
3903
	/* WaDisableDopClockGating */
3671
	I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
3904
	I915_WRITE(GEN7_ROW_CHICKEN2,
3672
		   GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
3905
		   _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
3673
 
3906
 
Line -... Line 3907...
-
 
3907
	/* WaForceL3Serialization */
3674
	/* WaApplyL3ControlAndL3ChickenMode requires those two on Ivy Bridge */
3908
	I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
3675
	I915_WRITE(GEN7_L3CNTLREG1, GEN7_WA_FOR_GEN7_L3_CONTROL);
3909
		   ~L3SQ_URB_READ_CAM_MATCH_DISABLE);
Line 3676... Line 3910...
3676
	I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER, GEN7_WA_L3_CHICKEN_MODE);
3910
 
Line 3729... Line 3963...
3729
		   SPRITED_FLIPDONE_INT_EN | SPRITEC_FLIPDONE_INT_EN |
3963
		   SPRITED_FLIPDONE_INT_EN | SPRITEC_FLIPDONE_INT_EN |
3730
		   PLANEB_FLIPDONE_INT_EN | PIPEA_LINE_COMPARE_INT_EN |
3964
		   PLANEB_FLIPDONE_INT_EN | PIPEA_LINE_COMPARE_INT_EN |
3731
		   PIPEA_HLINE_INT_EN | PIPEA_VBLANK_INT_EN |
3965
		   PIPEA_HLINE_INT_EN | PIPEA_VBLANK_INT_EN |
3732
		   SPRITEB_FLIPDONE_INT_EN | SPRITEA_FLIPDONE_INT_EN |
3966
		   SPRITEB_FLIPDONE_INT_EN | SPRITEA_FLIPDONE_INT_EN |
3733
		   PLANEA_FLIPDONE_INT_EN);
3967
		   PLANEA_FLIPDONE_INT_EN);
-
 
3968
 
-
 
3969
	/*
-
 
3970
	 * WaDisableVLVClockGating_VBIIssue
-
 
3971
	 * Disable clock gating on th GCFG unit to prevent a delay
-
 
3972
	 * in the reporting of vblank events.
-
 
3973
	 */
-
 
3974
	I915_WRITE(VLV_GUNIT_CLOCK_GATE, GCFG_DIS);
3734
}
3975
}
Line 3735... Line 3976...
3735
 
3976
 
3736
static void g4x_init_clock_gating(struct drm_device *dev)
3977
static void g4x_init_clock_gating(struct drm_device *dev)
3737
{
3978
{
Line 3747... Line 3988...
3747
		OVRUNIT_CLOCK_GATE_DISABLE |
3988
		OVRUNIT_CLOCK_GATE_DISABLE |
3748
		OVCUNIT_CLOCK_GATE_DISABLE;
3989
		OVCUNIT_CLOCK_GATE_DISABLE;
3749
	if (IS_GM45(dev))
3990
	if (IS_GM45(dev))
3750
		dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
3991
		dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
3751
	I915_WRITE(DSPCLK_GATE_D, dspclk_gate);
3992
	I915_WRITE(DSPCLK_GATE_D, dspclk_gate);
-
 
3993
 
-
 
3994
	/* WaDisableRenderCachePipelinedFlush */
-
 
3995
	I915_WRITE(CACHE_MODE_0,
-
 
3996
		   _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
3752
}
3997
}
Line 3753... Line 3998...
3753
 
3998
 
3754
static void crestline_init_clock_gating(struct drm_device *dev)
3999
static void crestline_init_clock_gating(struct drm_device *dev)
3755
{
4000
{
Line 3802... Line 4047...
3802
	struct drm_i915_private *dev_priv = dev->dev_private;
4047
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 3803... Line 4048...
3803
 
4048
 
3804
	I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE);
4049
	I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE);
Line 3805... Line -...
3805
}
-
 
3806
 
-
 
3807
static void ibx_init_clock_gating(struct drm_device *dev)
-
 
3808
{
-
 
3809
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3810
 
-
 
3811
	/*
-
 
3812
	 * On Ibex Peak and Cougar Point, we need to disable clock
-
 
3813
	 * gating for the panel power sequencer or it will fail to
-
 
3814
	 * start up when no ports are active.
-
 
3815
	 */
-
 
3816
	I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
-
 
3817
}
-
 
3818
 
-
 
3819
static void cpt_init_clock_gating(struct drm_device *dev)
-
 
3820
{
-
 
3821
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3822
	int pipe;
-
 
3823
 
-
 
3824
	/*
-
 
3825
	 * On Ibex Peak and Cougar Point, we need to disable clock
-
 
3826
	 * gating for the panel power sequencer or it will fail to
-
 
3827
	 * start up when no ports are active.
-
 
3828
	 */
-
 
3829
	I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
-
 
3830
	I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) |
-
 
3831
		   DPLS_EDP_PPS_FIX_DIS);
-
 
3832
	/* Without this, mode sets may fail silently on FDI */
-
 
3833
	for_each_pipe(pipe)
-
 
3834
		I915_WRITE(TRANS_CHICKEN2(pipe), TRANS_AUTOTRAIN_GEN_STALL_DIS);
-
 
3835
}
4050
}
3836
 
4051
 
3837
void intel_init_clock_gating(struct drm_device *dev)
4052
void intel_init_clock_gating(struct drm_device *dev)
Line 3838... Line 4053...
3838
{
4053
{
3839
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3840
 
-
 
3841
	dev_priv->display.init_clock_gating(dev);
-
 
3842
 
4054
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 3843... Line 4055...
3843
	if (dev_priv->display.init_pch_clock_gating)
4055
 
3844
		dev_priv->display.init_pch_clock_gating(dev);
4056
	dev_priv->display.init_clock_gating(dev);
3845
}
4057
}
Line 3865... Line 4077...
3865
	for (i = 0; i < ARRAY_SIZE(power_wells); i++) {
4077
	for (i = 0; i < ARRAY_SIZE(power_wells); i++) {
3866
		int well = I915_READ(power_wells[i]);
4078
		int well = I915_READ(power_wells[i]);
Line 3867... Line 4079...
3867
 
4079
 
3868
		if ((well & HSW_PWR_WELL_STATE) == 0) {
4080
		if ((well & HSW_PWR_WELL_STATE) == 0) {
3869
			I915_WRITE(power_wells[i], well & HSW_PWR_WELL_ENABLE);
4081
			I915_WRITE(power_wells[i], well & HSW_PWR_WELL_ENABLE);
3870
			if (wait_for(I915_READ(power_wells[i] & HSW_PWR_WELL_STATE), 20))
4082
			if (wait_for((I915_READ(power_wells[i]) & HSW_PWR_WELL_STATE), 20))
3871
				DRM_ERROR("Error enabling power well %lx\n", power_wells[i]);
4083
				DRM_ERROR("Error enabling power well %lx\n", power_wells[i]);
3872
		}
4084
		}
Line 3873... Line 4085...
3873
	}
4085
	}
Line 3903... Line 4115...
3903
	else if (IS_GEN5(dev))
4115
	else if (IS_GEN5(dev))
3904
		i915_ironlake_get_mem_freq(dev);
4116
		i915_ironlake_get_mem_freq(dev);
Line 3905... Line 4117...
3905
 
4117
 
3906
	/* For FIFO watermark updates */
4118
	/* For FIFO watermark updates */
3907
	if (HAS_PCH_SPLIT(dev)) {
-
 
3908
		if (HAS_PCH_IBX(dev))
-
 
3909
			dev_priv->display.init_pch_clock_gating = ibx_init_clock_gating;
-
 
3910
		else if (HAS_PCH_CPT(dev))
-
 
3911
			dev_priv->display.init_pch_clock_gating = cpt_init_clock_gating;
-
 
3912
 
4119
	if (HAS_PCH_SPLIT(dev)) {
3913
		if (IS_GEN5(dev)) {
4120
		if (IS_GEN5(dev)) {
3914
			if (I915_READ(MLTR_ILK) & ILK_SRLT_MASK)
4121
			if (I915_READ(MLTR_ILK) & ILK_SRLT_MASK)
3915
				dev_priv->display.update_wm = ironlake_update_wm;
4122
				dev_priv->display.update_wm = ironlake_update_wm;
3916
			else {
4123
			else {
Line 3930... Line 4137...
3930
			}
4137
			}
3931
			dev_priv->display.init_clock_gating = gen6_init_clock_gating;
4138
			dev_priv->display.init_clock_gating = gen6_init_clock_gating;
3932
		} else if (IS_IVYBRIDGE(dev)) {
4139
		} else if (IS_IVYBRIDGE(dev)) {
3933
			/* FIXME: detect B0+ stepping and use auto training */
4140
			/* FIXME: detect B0+ stepping and use auto training */
3934
			if (SNB_READ_WM0_LATENCY()) {
4141
			if (SNB_READ_WM0_LATENCY()) {
3935
				dev_priv->display.update_wm = sandybridge_update_wm;
4142
				dev_priv->display.update_wm = ivybridge_update_wm;
3936
				dev_priv->display.update_sprite_wm = sandybridge_update_sprite_wm;
4143
				dev_priv->display.update_sprite_wm = sandybridge_update_sprite_wm;
3937
			} else {
4144
			} else {
3938
				DRM_DEBUG_KMS("Failed to read display plane latency. "
4145
				DRM_DEBUG_KMS("Failed to read display plane latency. "
3939
					      "Disable CxSR\n");
4146
					      "Disable CxSR\n");
3940
				dev_priv->display.update_wm = NULL;
4147
				dev_priv->display.update_wm = NULL;
Line 4018... Line 4225...
4018
	 */
4225
	 */
4019
	if (wait_for_atomic_us((I915_READ_NOTRACE(GEN6_GT_THREAD_STATUS_REG) & gt_thread_status_mask) == 0, 500))
4226
	if (wait_for_atomic_us((I915_READ_NOTRACE(GEN6_GT_THREAD_STATUS_REG) & gt_thread_status_mask) == 0, 500))
4020
		DRM_ERROR("GT thread status wait timed out\n");
4227
		DRM_ERROR("GT thread status wait timed out\n");
4021
}
4228
}
Line -... Line 4229...
-
 
4229
 
-
 
4230
static void __gen6_gt_force_wake_reset(struct drm_i915_private *dev_priv)
-
 
4231
{
-
 
4232
	I915_WRITE_NOTRACE(FORCEWAKE, 0);
-
 
4233
	POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
-
 
4234
}
4022
 
4235
 
4023
static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
4236
static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
4024
{
4237
{
Line 4025... Line 4238...
4025
	u32 forcewake_ack;
4238
	u32 forcewake_ack;
Line 4031... Line 4244...
4031
 
4244
 
4032
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1) == 0,
4245
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1) == 0,
4033
			    FORCEWAKE_ACK_TIMEOUT_MS))
4246
			    FORCEWAKE_ACK_TIMEOUT_MS))
Line 4034... Line 4247...
4034
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4247
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4035
 
4248
 
Line 4036... Line 4249...
4036
	I915_WRITE_NOTRACE(FORCEWAKE, 1);
4249
	I915_WRITE_NOTRACE(FORCEWAKE, FORCEWAKE_KERNEL);
4037
	POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
4250
	POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
4038
 
4251
 
Line 4039... Line 4252...
4039
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1),
4252
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1),
4040
			    FORCEWAKE_ACK_TIMEOUT_MS))
4253
			    FORCEWAKE_ACK_TIMEOUT_MS))
Line -... Line 4254...
-
 
4254
		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
-
 
4255
 
-
 
4256
	__gen6_gt_wait_for_thread_c0(dev_priv);
-
 
4257
}
-
 
4258
 
-
 
4259
static void __gen6_gt_force_wake_mt_reset(struct drm_i915_private *dev_priv)
-
 
4260
{
4041
		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
4261
	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(0xffff));
4042
 
4262
	/* something from same cacheline, but !FORCEWAKE_MT */
4043
	__gen6_gt_wait_for_thread_c0(dev_priv);
4263
	POSTING_READ(ECOBUS);
Line 4044... Line 4264...
4044
}
4264
}
Line 4054... Line 4274...
4054
 
4274
 
4055
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1) == 0,
4275
	if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1) == 0,
4056
			    FORCEWAKE_ACK_TIMEOUT_MS))
4276
			    FORCEWAKE_ACK_TIMEOUT_MS))
Line 4057... Line 4277...
4057
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4277
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4058
 
4278
 
-
 
4279
	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
Line 4059... Line 4280...
4059
	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_ENABLE(1));
4280
	/* something from same cacheline, but !FORCEWAKE_MT */
4060
	POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */
4281
	POSTING_READ(ECOBUS);
4061
 
4282
 
Line 4092... Line 4313...
4092
}
4313
}
Line 4093... Line 4314...
4093
 
4314
 
4094
static void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
4315
static void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
4095
{
4316
{
4096
	I915_WRITE_NOTRACE(FORCEWAKE, 0);
4317
	I915_WRITE_NOTRACE(FORCEWAKE, 0);
-
 
4318
	/* something from same cacheline, but !FORCEWAKE */
4097
	/* gen6_gt_check_fifodbg doubles as the POSTING_READ */
4319
	POSTING_READ(ECOBUS);
4098
	gen6_gt_check_fifodbg(dev_priv);
4320
	gen6_gt_check_fifodbg(dev_priv);
Line 4099... Line 4321...
4099
}
4321
}
4100
 
4322
 
4101
static void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv)
4323
static void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv)
4102
{
4324
{
-
 
4325
	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
4103
	I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(1));
4326
	/* something from same cacheline, but !FORCEWAKE_MT */
4104
	/* gen6_gt_check_fifodbg doubles as the POSTING_READ */
4327
	POSTING_READ(ECOBUS);
Line 4105... Line 4328...
4105
	gen6_gt_check_fifodbg(dev_priv);
4328
	gen6_gt_check_fifodbg(dev_priv);
4106
}
4329
}
Line 4136... Line 4359...
4136
	dev_priv->gt_fifo_count--;
4359
	dev_priv->gt_fifo_count--;
Line 4137... Line 4360...
4137
 
4360
 
4138
	return ret;
4361
	return ret;
Line -... Line 4362...
-
 
4362
}
-
 
4363
 
-
 
4364
static void vlv_force_wake_reset(struct drm_i915_private *dev_priv)
-
 
4365
{
-
 
4366
	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(0xffff));
-
 
4367
	/* something from same cacheline, but !FORCEWAKE_VLV */
-
 
4368
	POSTING_READ(FORCEWAKE_ACK_VLV);
4139
}
4369
}
4140
 
4370
 
4141
static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
4371
static void vlv_force_wake_get(struct drm_i915_private *dev_priv)
4142
{
4372
{
4143
	if (wait_for_atomic((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0,
4373
	if (wait_for_atomic((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1) == 0,
Line 4144... Line 4374...
4144
			    FORCEWAKE_ACK_TIMEOUT_MS))
4374
			    FORCEWAKE_ACK_TIMEOUT_MS))
Line 4145... Line 4375...
4145
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4375
		DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");
4146
 
4376
 
4147
	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(1));
4377
	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
Line 4148... Line 4378...
4148
 
4378
 
4149
	if (wait_for_atomic((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1),
4379
	if (wait_for_atomic((I915_READ_NOTRACE(FORCEWAKE_ACK_VLV) & 1),
Line 4150... Line 4380...
4150
			    FORCEWAKE_ACK_TIMEOUT_MS))
4380
			    FORCEWAKE_ACK_TIMEOUT_MS))
4151
		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
4381
		DRM_ERROR("Timed out waiting for forcewake to ack request.\n");
4152
 
4382
 
4153
	__gen6_gt_wait_for_thread_c0(dev_priv);
4383
	__gen6_gt_wait_for_thread_c0(dev_priv);
-
 
4384
}
4154
}
4385
 
4155
 
4386
static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
Line -... Line 4387...
-
 
4387
{
-
 
4388
	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
-
 
4389
	/* something from same cacheline, but !FORCEWAKE_VLV */
-
 
4390
	POSTING_READ(FORCEWAKE_ACK_VLV);
-
 
4391
	gen6_gt_check_fifodbg(dev_priv);
-
 
4392
}
-
 
4393
 
-
 
4394
void intel_gt_reset(struct drm_device *dev)
-
 
4395
{
-
 
4396
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4397
 
-
 
4398
	if (IS_VALLEYVIEW(dev)) {
-
 
4399
		vlv_force_wake_reset(dev_priv);
4156
static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
4400
	} else if (INTEL_INFO(dev)->gen >= 6) {
4157
{
4401
		__gen6_gt_force_wake_reset(dev_priv);
4158
	I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(1));
4402
		if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
Line 4159... Line 4403...
4159
	/* The below doubles as a POSTING_READ */
4403
			__gen6_gt_force_wake_mt_reset(dev_priv);
Line -... Line 4404...
-
 
4404
	}
-
 
4405
}
4160
	gen6_gt_check_fifodbg(dev_priv);
4406
 
4161
}
4407
void intel_gt_init(struct drm_device *dev)
4162
 
4408
{
-
 
4409
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4410
 
-
 
4411
	spin_lock_init(&dev_priv->gt_lock);
4163
void intel_gt_init(struct drm_device *dev)
4412
 
4164
{
4413
	intel_gt_reset(dev);
4165
	struct drm_i915_private *dev_priv = dev->dev_private;
4414
 
-
 
4415
	if (IS_VALLEYVIEW(dev)) {
-
 
4416
		dev_priv->gt.force_wake_get = vlv_force_wake_get;
Line 4166... Line 4417...
4166
 
4417
		dev_priv->gt.force_wake_put = vlv_force_wake_put;
4167
	spin_lock_init(&dev_priv->gt_lock);
-
 
4168
 
-
 
4169
	if (IS_VALLEYVIEW(dev)) {
4418
	} else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) {
4170
		dev_priv->gt.force_wake_get = vlv_force_wake_get;
-
 
4171
		dev_priv->gt.force_wake_put = vlv_force_wake_put;
-
 
4172
	} else if (INTEL_INFO(dev)->gen >= 6) {
-
 
4173
		dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
-
 
4174
		dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
-
 
4175
 
-
 
4176
		/* IVB configs may use multi-threaded forcewake */
-
 
4177
		if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) {
-
 
4178
			u32 ecobus;
-
 
4179
 
-
 
4180
			/* A small trick here - if the bios hasn't configured
-
 
4181
			 * MT forcewake, and if the device is in RC6, then
4419
		dev_priv->gt.force_wake_get = __gen6_gt_force_wake_mt_get;
Line 4182... Line 4420...
4182
			 * force_wake_mt_get will not wake the device and the
4420
		dev_priv->gt.force_wake_put = __gen6_gt_force_wake_mt_put;
4183
			 * ECOBUS read will return zero. Which will be
4421
	} else if (IS_GEN6(dev)) {
4184
			 * (correctly) interpreted by the test below as MT
-
 
4185
			 * forcewake being disabled.
-
 
4186
			 */
-
 
4187
			mutex_lock(&dev->struct_mutex);
4422
		dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
4188
			__gen6_gt_force_wake_mt_get(dev_priv);
4423
		dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
-
 
4424
	}
-
 
4425
}
-
 
4426
 
-
 
4427
int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u8 mbox, u32 *val)
-
 
4428
{
-
 
4429
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
-
 
4430
 
-
 
4431
	if (I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
4189
			ecobus = I915_READ_NOTRACE(ECOBUS);
4432
		DRM_DEBUG_DRIVER("warning: pcode (read) mailbox access failed\n");
-
 
4433
		return -EAGAIN;
-
 
4434
	}
-
 
4435
 
-
 
4436
	I915_WRITE(GEN6_PCODE_DATA, *val);
-
 
4437
	I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
-
 
4438
 
-
 
4439
	if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) == 0,
-
 
4440
		     500)) {
-
 
4441
		DRM_ERROR("timeout waiting for pcode read (%d) to finish\n", mbox);
-
 
4442
		return -ETIMEDOUT;
-
 
4443
			}
-
 
4444
 
-
 
4445
	*val = I915_READ(GEN6_PCODE_DATA);
-
 
4446
	I915_WRITE(GEN6_PCODE_DATA, 0);
4190
			__gen6_gt_force_wake_mt_put(dev_priv);
4447
 
-
 
4448
	return 0;
-
 
4449
}
-
 
4450
 
-
 
4451
int sandybridge_pcode_write(struct drm_i915_private *dev_priv, u8 mbox, u32 val)
-
 
4452
{
-
 
4453
	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
-
 
4454
 
-
 
4455
	if (I915_READ(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY) {
4191
			mutex_unlock(&dev->struct_mutex);
4456
		DRM_DEBUG_DRIVER("warning: pcode (write) mailbox access failed\n");
Line -... Line 4457...
-
 
4457
		return -EAGAIN;
-
 
4458
		}
-
 
4459
 
-
 
4460
	I915_WRITE(GEN6_PCODE_DATA, val);