i915_pci.c 23.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Copyright © 2016 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 */

25
#include <linux/console.h>
26 27 28
#include <linux/vgaarb.h>
#include <linux/vga_switcheroo.h>

29 30
#include <drm/drm_drv.h>

31
#include "i915_drv.h"
32
#include "i915_globals.h"
33
#include "i915_selftest.h"
34

35
#define PLATFORM(x) .platform = (x), .platform_mask = BIT(x)
36 37
#define GEN(x) .gen = (x), .gen_mask = BIT((x) - 1)

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#define I845_PIPE_OFFSETS \
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET,	\
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
	}

#define I9XX_PIPE_OFFSETS \
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET,	\
		[TRANSCODER_B] = PIPE_B_OFFSET, \
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
		[TRANSCODER_B] = TRANSCODER_B_OFFSET, \
	}

#define IVB_PIPE_OFFSETS \
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET,	\
		[TRANSCODER_B] = PIPE_B_OFFSET, \
		[TRANSCODER_C] = PIPE_C_OFFSET, \
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
		[TRANSCODER_B] = TRANSCODER_B_OFFSET, \
		[TRANSCODER_C] = TRANSCODER_C_OFFSET, \
	}

#define HSW_PIPE_OFFSETS \
69 70 71 72 73 74 75 76 77 78 79 80
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET,	\
		[TRANSCODER_B] = PIPE_B_OFFSET, \
		[TRANSCODER_C] = PIPE_C_OFFSET, \
		[TRANSCODER_EDP] = PIPE_EDP_OFFSET, \
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
		[TRANSCODER_B] = TRANSCODER_B_OFFSET, \
		[TRANSCODER_C] = TRANSCODER_C_OFFSET, \
		[TRANSCODER_EDP] = TRANSCODER_EDP_OFFSET, \
	}
81

82
#define CHV_PIPE_OFFSETS \
83 84 85 86 87 88 89 90 91 92
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET, \
		[TRANSCODER_B] = PIPE_B_OFFSET, \
		[TRANSCODER_C] = CHV_PIPE_C_OFFSET, \
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
		[TRANSCODER_B] = TRANSCODER_B_OFFSET, \
		[TRANSCODER_C] = CHV_TRANSCODER_C_OFFSET, \
	}
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
#define I845_CURSOR_OFFSETS \
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
	}

#define I9XX_CURSOR_OFFSETS \
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
		[PIPE_B] = CURSOR_B_OFFSET, \
	}

#define CHV_CURSOR_OFFSETS \
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
		[PIPE_B] = CURSOR_B_OFFSET, \
		[PIPE_C] = CHV_CURSOR_C_OFFSET, \
	}
111 112

#define IVB_CURSOR_OFFSETS \
113 114 115 116 117
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
		[PIPE_B] = IVB_CURSOR_B_OFFSET, \
		[PIPE_C] = IVB_CURSOR_C_OFFSET, \
	}
118 119 120 121

#define BDW_COLORS \
	.color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
#define CHV_COLORS \
122 123 124 125
	.color = { .degamma_lut_size = 65, .gamma_lut_size = 257, \
		   .degamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING, \
		   .gamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING, \
	}
R
Rodrigo Vivi 已提交
126
#define GLK_COLORS \
127
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 1024, \
128 129 130
		   .degamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING | \
					DRM_COLOR_LUT_EQUAL_CHANNELS, \
	}
131

132
/* Keep in gen based order, and chronological order within a gen */
133 134 135 136

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
#define I830_FEATURES \
	GEN(2), \
	.is_mobile = 1, \
	.num_pipes = 2, \
	.display.has_overlay = 1, \
	.display.cursor_needs_physical = 1, \
	.display.overlay_needs_physical = 1, \
	.display.has_gmch = 1, \
	.gpu_reset_clobbers_display = true, \
	.hws_needs_physical = 1, \
	.unfenced_needs_alignment = 1, \
	.engine_mask = BIT(RCS0), \
	.has_snoop = true, \
	.has_coherent_ggtt = false, \
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES

#define I845_FEATURES \
156 157
	GEN(2), \
	.num_pipes = 1, \
158 159
	.display.has_overlay = 1, \
	.display.overlay_needs_physical = 1, \
R
Rodrigo Vivi 已提交
160
	.display.has_gmch = 1, \
161
	.gpu_reset_clobbers_display = true, \
162
	.hws_needs_physical = 1, \
163
	.unfenced_needs_alignment = 1, \
164
	.engine_mask = BIT(RCS0), \
165
	.has_snoop = true, \
166
	.has_coherent_ggtt = false, \
167 168 169
	I845_PIPE_OFFSETS, \
	I845_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
170

171
static const struct intel_device_info intel_i830_info = {
172
	I830_FEATURES,
173
	PLATFORM(INTEL_I830),
174 175
};

176
static const struct intel_device_info intel_i845g_info = {
177
	I845_FEATURES,
178
	PLATFORM(INTEL_I845G),
179 180
};

181
static const struct intel_device_info intel_i85x_info = {
182
	I830_FEATURES,
183
	PLATFORM(INTEL_I85X),
184
	.display.has_fbc = 1,
185 186
};

187
static const struct intel_device_info intel_i865g_info = {
188
	I845_FEATURES,
189
	PLATFORM(INTEL_I865G),
190 191
};

192
#define GEN3_FEATURES \
193 194
	GEN(3), \
	.num_pipes = 2, \
R
Rodrigo Vivi 已提交
195
	.display.has_gmch = 1, \
196
	.gpu_reset_clobbers_display = true, \
197
	.engine_mask = BIT(RCS0), \
198
	.has_snoop = true, \
199
	.has_coherent_ggtt = true, \
200 201 202
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
203

204
static const struct intel_device_info intel_i915g_info = {
205
	GEN3_FEATURES,
206
	PLATFORM(INTEL_I915G),
207
	.has_coherent_ggtt = false,
208 209 210
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
211
	.hws_needs_physical = 1,
212
	.unfenced_needs_alignment = 1,
213
};
214

215
static const struct intel_device_info intel_i915gm_info = {
216
	GEN3_FEATURES,
217
	PLATFORM(INTEL_I915GM),
218
	.is_mobile = 1,
219 220 221 222 223
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
	.display.supports_tv = 1,
	.display.has_fbc = 1,
224
	.hws_needs_physical = 1,
225
	.unfenced_needs_alignment = 1,
226
};
227

228
static const struct intel_device_info intel_i945g_info = {
229
	GEN3_FEATURES,
230
	PLATFORM(INTEL_I945G),
231 232 233 234
	.display.has_hotplug = 1,
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
235
	.hws_needs_physical = 1,
236
	.unfenced_needs_alignment = 1,
237
};
238

239
static const struct intel_device_info intel_i945gm_info = {
240
	GEN3_FEATURES,
241 242
	PLATFORM(INTEL_I945GM),
	.is_mobile = 1,
243 244 245 246 247 248
	.display.has_hotplug = 1,
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
	.display.supports_tv = 1,
	.display.has_fbc = 1,
249
	.hws_needs_physical = 1,
250
	.unfenced_needs_alignment = 1,
251 252
};

253
static const struct intel_device_info intel_g33_info = {
254
	GEN3_FEATURES,
255
	PLATFORM(INTEL_G33),
256 257
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
258 259
};

260
static const struct intel_device_info intel_pineview_info = {
261
	GEN3_FEATURES,
262 263
	PLATFORM(INTEL_PINEVIEW),
	.is_mobile = 1,
264 265
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
266 267
};

268
#define GEN4_FEATURES \
269 270
	GEN(4), \
	.num_pipes = 2, \
271
	.display.has_hotplug = 1, \
R
Rodrigo Vivi 已提交
272
	.display.has_gmch = 1, \
273
	.gpu_reset_clobbers_display = true, \
274
	.engine_mask = BIT(RCS0), \
275
	.has_snoop = true, \
276
	.has_coherent_ggtt = true, \
277 278 279
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
280

281
static const struct intel_device_info intel_i965g_info = {
282
	GEN4_FEATURES,
283
	PLATFORM(INTEL_I965G),
284
	.display.has_overlay = 1,
285
	.hws_needs_physical = 1,
286
	.has_snoop = false,
287 288
};

289
static const struct intel_device_info intel_i965gm_info = {
290
	GEN4_FEATURES,
291
	PLATFORM(INTEL_I965GM),
292 293 294 295
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.has_overlay = 1,
	.display.supports_tv = 1,
296
	.hws_needs_physical = 1,
297
	.has_snoop = false,
298 299
};

300
static const struct intel_device_info intel_g45_info = {
301
	GEN4_FEATURES,
302
	PLATFORM(INTEL_G45),
303
	.engine_mask = BIT(RCS0) | BIT(VCS0),
304
	.gpu_reset_clobbers_display = false,
305 306
};

307
static const struct intel_device_info intel_gm45_info = {
308
	GEN4_FEATURES,
309
	PLATFORM(INTEL_GM45),
310 311 312
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.supports_tv = 1,
313
	.engine_mask = BIT(RCS0) | BIT(VCS0),
314
	.gpu_reset_clobbers_display = false,
315 316
};

317
#define GEN5_FEATURES \
318 319
	GEN(5), \
	.num_pipes = 2, \
320
	.display.has_hotplug = 1, \
321
	.engine_mask = BIT(RCS0) | BIT(VCS0), \
322
	.has_snoop = true, \
323
	.has_coherent_ggtt = true, \
324 325
	/* ilk does support rc6, but we do not implement [power] contexts */ \
	.has_rc6 = 0, \
326 327 328
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
329

330
static const struct intel_device_info intel_ironlake_d_info = {
331
	GEN5_FEATURES,
332
	PLATFORM(INTEL_IRONLAKE),
333 334
};

335
static const struct intel_device_info intel_ironlake_m_info = {
336
	GEN5_FEATURES,
337
	PLATFORM(INTEL_IRONLAKE),
338 339
	.is_mobile = 1,
	.display.has_fbc = 1,
340 341
};

342
#define GEN6_FEATURES \
343 344
	GEN(6), \
	.num_pipes = 2, \
345 346
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
347
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
348
	.has_coherent_ggtt = true, \
349
	.has_llc = 1, \
350
	.has_rc6 = 1, \
351
	.has_rc6p = 1, \
352 353
	.ppgtt_type = INTEL_PPGTT_ALIASING, \
	.ppgtt_size = 31, \
354 355 356
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
357

358 359
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
360
	PLATFORM(INTEL_SANDYBRIDGE)
361

362
static const struct intel_device_info intel_sandybridge_d_gt1_info = {
363 364
	SNB_D_PLATFORM,
	.gt = 1,
365 366
};

367
static const struct intel_device_info intel_sandybridge_d_gt2_info = {
368 369 370 371 372 373
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
374
	PLATFORM(INTEL_SANDYBRIDGE), \
375 376 377
	.is_mobile = 1


378
static const struct intel_device_info intel_sandybridge_m_gt1_info = {
379 380 381 382
	SNB_M_PLATFORM,
	.gt = 1,
};

383
static const struct intel_device_info intel_sandybridge_m_gt2_info = {
384 385
	SNB_M_PLATFORM,
	.gt = 2,
386 387 388
};

#define GEN7_FEATURES  \
389 390
	GEN(7), \
	.num_pipes = 3, \
391 392
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
393
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
394
	.has_coherent_ggtt = true, \
395
	.has_llc = 1, \
396
	.has_rc6 = 1, \
397
	.has_rc6p = 1, \
398 399
	.ppgtt_type = INTEL_PPGTT_FULL, \
	.ppgtt_size = 31, \
400 401 402
	IVB_PIPE_OFFSETS, \
	IVB_CURSOR_OFFSETS, \
	GEN_DEFAULT_PAGE_SIZES
403

404 405
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
406
	PLATFORM(INTEL_IVYBRIDGE), \
407 408
	.has_l3_dpf = 1

409
static const struct intel_device_info intel_ivybridge_d_gt1_info = {
410 411
	IVB_D_PLATFORM,
	.gt = 1,
412 413
};

414
static const struct intel_device_info intel_ivybridge_d_gt2_info = {
415 416 417 418 419 420
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
421
	PLATFORM(INTEL_IVYBRIDGE), \
422 423 424
	.is_mobile = 1, \
	.has_l3_dpf = 1

425
static const struct intel_device_info intel_ivybridge_m_gt1_info = {
426 427 428 429
	IVB_M_PLATFORM,
	.gt = 1,
};

430
static const struct intel_device_info intel_ivybridge_m_gt2_info = {
431 432
	IVB_M_PLATFORM,
	.gt = 2,
433 434
};

435
static const struct intel_device_info intel_ivybridge_q_info = {
436
	GEN7_FEATURES,
437
	PLATFORM(INTEL_IVYBRIDGE),
438
	.gt = 2,
439
	.num_pipes = 0, /* legal, last one wins */
440
	.has_l3_dpf = 1,
441 442
};

443
static const struct intel_device_info intel_valleyview_info = {
444
	PLATFORM(INTEL_VALLEYVIEW),
445
	GEN(7),
446 447 448 449
	.is_lp = 1,
	.num_pipes = 2,
	.has_runtime_pm = 1,
	.has_rc6 = 1,
R
Rodrigo Vivi 已提交
450
	.display.has_gmch = 1,
451
	.display.has_hotplug = 1,
452 453
	.ppgtt_type = INTEL_PPGTT_FULL,
	.ppgtt_size = 31,
454
	.has_snoop = true,
455
	.has_coherent_ggtt = false,
456
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0),
457
	.display_mmio_offset = VLV_DISPLAY_BASE,
458 459
	I9XX_PIPE_OFFSETS,
	I9XX_CURSOR_OFFSETS,
460
	GEN_DEFAULT_PAGE_SIZES,
461 462
};

463
#define G75_FEATURES  \
464
	GEN7_FEATURES, \
465
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
466
	.display.has_ddi = 1, \
467
	.has_fpga_dbg = 1, \
468 469
	.display.has_psr = 1, \
	.display.has_dp_mst = 1, \
470
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
471
	HSW_PIPE_OFFSETS, \
472
	.has_runtime_pm = 1
473

474
#define HSW_PLATFORM \
475
	G75_FEATURES, \
476
	PLATFORM(INTEL_HASWELL), \
477 478
	.has_l3_dpf = 1

479
static const struct intel_device_info intel_haswell_gt1_info = {
480 481 482 483
	HSW_PLATFORM,
	.gt = 1,
};

484
static const struct intel_device_info intel_haswell_gt2_info = {
485 486 487 488
	HSW_PLATFORM,
	.gt = 2,
};

489
static const struct intel_device_info intel_haswell_gt3_info = {
490 491
	HSW_PLATFORM,
	.gt = 3,
492 493
};

494 495
#define GEN8_FEATURES \
	G75_FEATURES, \
496
	GEN(8), \
497
	BDW_COLORS, \
498 499
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_2M, \
500
	.has_logical_ring_contexts = 1, \
501
	.ppgtt_type = INTEL_PPGTT_FULL, \
502
	.ppgtt_size = 48, \
503 504
	.has_64bit_reloc = 1, \
	.has_reset_engine = 1
505

506
#define BDW_PLATFORM \
507
	GEN8_FEATURES, \
508
	PLATFORM(INTEL_BROADWELL)
509

510
static const struct intel_device_info intel_broadwell_gt1_info = {
511 512 513 514
	BDW_PLATFORM,
	.gt = 1,
};

515
static const struct intel_device_info intel_broadwell_gt2_info = {
516
	BDW_PLATFORM,
517 518 519
	.gt = 2,
};

520
static const struct intel_device_info intel_broadwell_rsvd_info = {
521 522 523 524 525
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
526 527
};

528
static const struct intel_device_info intel_broadwell_gt3_info = {
529
	BDW_PLATFORM,
530
	.gt = 3,
531 532
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
533 534
};

535
static const struct intel_device_info intel_cherryview_info = {
536
	PLATFORM(INTEL_CHERRYVIEW),
537 538
	GEN(8),
	.num_pipes = 3,
539
	.display.has_hotplug = 1,
540
	.is_lp = 1,
541
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0),
542
	.has_64bit_reloc = 1,
543
	.has_runtime_pm = 1,
544
	.has_rc6 = 1,
545
	.has_logical_ring_contexts = 1,
R
Rodrigo Vivi 已提交
546
	.display.has_gmch = 1,
547 548
	.ppgtt_type = INTEL_PPGTT_FULL,
	.ppgtt_size = 32,
549
	.has_reset_engine = 1,
550
	.has_snoop = true,
551
	.has_coherent_ggtt = false,
552
	.display_mmio_offset = VLV_DISPLAY_BASE,
553 554
	CHV_PIPE_OFFSETS,
	CHV_CURSOR_OFFSETS,
555
	CHV_COLORS,
556
	GEN_DEFAULT_PAGE_SIZES,
557 558
};

559
#define GEN9_DEFAULT_PAGE_SIZES \
560
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
561 562
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M
563

564 565
#define GEN9_FEATURES \
	GEN8_FEATURES, \
566
	GEN(9), \
567
	GEN9_DEFAULT_PAGE_SIZES, \
C
Chris Wilson 已提交
568
	.has_logical_ring_preemption = 1, \
569
	.display.has_csr = 1, \
570
	.has_guc = 1, \
571
	.display.has_ipc = 1, \
572 573
	.ddb_size = 896

574 575
#define SKL_PLATFORM \
	GEN9_FEATURES, \
576
	/* Display WA #0477 WaDisableIPC: skl */ \
577
	.display.has_ipc = 0, \
578
	PLATFORM(INTEL_SKYLAKE)
579

580
static const struct intel_device_info intel_skylake_gt1_info = {
581
	SKL_PLATFORM,
582
	.gt = 1,
583 584
};

585
static const struct intel_device_info intel_skylake_gt2_info = {
586
	SKL_PLATFORM,
587 588 589 590 591
	.gt = 2,
};

#define SKL_GT3_PLUS_PLATFORM \
	SKL_PLATFORM, \
592 593
	.engine_mask = \
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1)
594 595


596
static const struct intel_device_info intel_skylake_gt3_info = {
597 598 599 600
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

601
static const struct intel_device_info intel_skylake_gt4_info = {
602 603
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
604 605
};

606
#define GEN9_LP_FEATURES \
607
	GEN(9), \
608
	.is_lp = 1, \
609
	.display.has_hotplug = 1, \
610
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
611 612
	.num_pipes = 3, \
	.has_64bit_reloc = 1, \
613
	.display.has_ddi = 1, \
614
	.has_fpga_dbg = 1, \
615 616
	.display.has_fbc = 1, \
	.display.has_psr = 1, \
617
	.has_runtime_pm = 1, \
618
	.display.has_csr = 1, \
619
	.has_rc6 = 1, \
620
	.display.has_dp_mst = 1, \
621
	.has_logical_ring_contexts = 1, \
C
Chris Wilson 已提交
622
	.has_logical_ring_preemption = 1, \
623
	.has_guc = 1, \
624
	.ppgtt_type = INTEL_PPGTT_FULL, \
625
	.ppgtt_size = 48, \
626
	.has_reset_engine = 1, \
627
	.has_snoop = true, \
628
	.has_coherent_ggtt = false, \
629
	.display.has_ipc = 1, \
630
	HSW_PIPE_OFFSETS, \
631
	IVB_CURSOR_OFFSETS, \
632 633
	BDW_COLORS, \
	GEN9_DEFAULT_PAGE_SIZES
634

635
static const struct intel_device_info intel_broxton_info = {
636
	GEN9_LP_FEATURES,
637
	PLATFORM(INTEL_BROXTON),
638
	.ddb_size = 512,
639 640
};

641
static const struct intel_device_info intel_geminilake_info = {
642
	GEN9_LP_FEATURES,
643
	PLATFORM(INTEL_GEMINILAKE),
644
	.ddb_size = 1024,
R
Rodrigo Vivi 已提交
645
	GLK_COLORS,
646 647
};

648
#define KBL_PLATFORM \
649
	GEN9_FEATURES, \
650
	PLATFORM(INTEL_KABYLAKE)
651

652
static const struct intel_device_info intel_kabylake_gt1_info = {
653
	KBL_PLATFORM,
654 655 656
	.gt = 1,
};

657
static const struct intel_device_info intel_kabylake_gt2_info = {
658 659
	KBL_PLATFORM,
	.gt = 2,
660 661
};

662
static const struct intel_device_info intel_kabylake_gt3_info = {
663
	KBL_PLATFORM,
664
	.gt = 3,
665 666
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
667 668
};

669
#define CFL_PLATFORM \
670
	GEN9_FEATURES, \
671
	PLATFORM(INTEL_COFFEELAKE)
672

673
static const struct intel_device_info intel_coffeelake_gt1_info = {
674 675 676 677
	CFL_PLATFORM,
	.gt = 1,
};

678
static const struct intel_device_info intel_coffeelake_gt2_info = {
679
	CFL_PLATFORM,
680
	.gt = 2,
681 682
};

683
static const struct intel_device_info intel_coffeelake_gt3_info = {
684
	CFL_PLATFORM,
685
	.gt = 3,
686 687
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
688 689
};

690 691
#define GEN10_FEATURES \
	GEN9_FEATURES, \
692
	GEN(10), \
693
	.ddb_size = 1024, \
694
	.has_coherent_ggtt = false, \
R
Rodrigo Vivi 已提交
695
	GLK_COLORS
696

697
static const struct intel_device_info intel_cannonlake_info = {
698
	GEN10_FEATURES,
699
	PLATFORM(INTEL_CANNONLAKE),
700
	.gt = 2,
701 702
};

703 704
#define GEN11_FEATURES \
	GEN10_FEATURES, \
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET, \
		[TRANSCODER_B] = PIPE_B_OFFSET, \
		[TRANSCODER_C] = PIPE_C_OFFSET, \
		[TRANSCODER_EDP] = PIPE_EDP_OFFSET, \
		[TRANSCODER_DSI_0] = PIPE_DSI0_OFFSET, \
		[TRANSCODER_DSI_1] = PIPE_DSI1_OFFSET, \
	}, \
	.trans_offsets = { \
		[TRANSCODER_A] = TRANSCODER_A_OFFSET, \
		[TRANSCODER_B] = TRANSCODER_B_OFFSET, \
		[TRANSCODER_C] = TRANSCODER_C_OFFSET, \
		[TRANSCODER_EDP] = TRANSCODER_EDP_OFFSET, \
		[TRANSCODER_DSI_0] = TRANSCODER_DSI0_OFFSET, \
		[TRANSCODER_DSI_1] = TRANSCODER_DSI1_OFFSET, \
	}, \
721
	GEN(11), \
722
	.ddb_size = 2048, \
723 724
	.has_logical_ring_elsq = 1, \
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 1024 }
725

726
static const struct intel_device_info intel_icelake_11_info = {
727
	GEN11_FEATURES,
728
	PLATFORM(INTEL_ICELAKE),
729 730
	.engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
731 732
};

733
#undef GEN
734
#undef PLATFORM
735

736 737 738 739 740 741 742 743
/*
 * Make sure any device matches here are from most specific to most
 * general.  For example, since the Quanta match is based on the subsystem
 * and subvendor IDs, we need it to come before the more general IVB
 * PCI ID matches, otherwise we'll use the wrong info struct above.
 */
static const struct pci_device_id pciidlist[] = {
	INTEL_I830_IDS(&intel_i830_info),
744
	INTEL_I845G_IDS(&intel_i845g_info),
745 746 747 748 749 750 751 752 753 754 755 756 757 758
	INTEL_I85X_IDS(&intel_i85x_info),
	INTEL_I865G_IDS(&intel_i865g_info),
	INTEL_I915G_IDS(&intel_i915g_info),
	INTEL_I915GM_IDS(&intel_i915gm_info),
	INTEL_I945G_IDS(&intel_i945g_info),
	INTEL_I945GM_IDS(&intel_i945gm_info),
	INTEL_I965G_IDS(&intel_i965g_info),
	INTEL_G33_IDS(&intel_g33_info),
	INTEL_I965GM_IDS(&intel_i965gm_info),
	INTEL_GM45_IDS(&intel_gm45_info),
	INTEL_G45_IDS(&intel_g45_info),
	INTEL_PINEVIEW_IDS(&intel_pineview_info),
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
759 760 761 762
	INTEL_SNB_D_GT1_IDS(&intel_sandybridge_d_gt1_info),
	INTEL_SNB_D_GT2_IDS(&intel_sandybridge_d_gt2_info),
	INTEL_SNB_M_GT1_IDS(&intel_sandybridge_m_gt1_info),
	INTEL_SNB_M_GT2_IDS(&intel_sandybridge_m_gt2_info),
763
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
764 765 766 767 768 769 770
	INTEL_IVB_M_GT1_IDS(&intel_ivybridge_m_gt1_info),
	INTEL_IVB_M_GT2_IDS(&intel_ivybridge_m_gt2_info),
	INTEL_IVB_D_GT1_IDS(&intel_ivybridge_d_gt1_info),
	INTEL_IVB_D_GT2_IDS(&intel_ivybridge_d_gt2_info),
	INTEL_HSW_GT1_IDS(&intel_haswell_gt1_info),
	INTEL_HSW_GT2_IDS(&intel_haswell_gt2_info),
	INTEL_HSW_GT3_IDS(&intel_haswell_gt3_info),
771
	INTEL_VLV_IDS(&intel_valleyview_info),
772 773
	INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
	INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
774
	INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
775
	INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
776
	INTEL_CHV_IDS(&intel_cherryview_info),
777 778
	INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
	INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
779
	INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
780
	INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
781
	INTEL_BXT_IDS(&intel_broxton_info),
782
	INTEL_GLK_IDS(&intel_geminilake_info),
783 784
	INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
	INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
785 786
	INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
	INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
787
	INTEL_AML_KBL_GT2_IDS(&intel_kabylake_gt2_info),
788 789
	INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
790
	INTEL_CFL_H_GT1_IDS(&intel_coffeelake_gt1_info),
791
	INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
792
	INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
793
	INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
794 795
	INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
796
	INTEL_AML_CFL_GT2_IDS(&intel_coffeelake_gt2_info),
797
	INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
A
Anusha Srivatsa 已提交
798 799
	INTEL_CML_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CML_GT2_IDS(&intel_coffeelake_gt2_info),
800
	INTEL_CNL_IDS(&intel_cannonlake_info),
P
Paulo Zanoni 已提交
801
	INTEL_ICL_11_IDS(&intel_icelake_11_info),
802 803 804 805
	{0, 0, 0}
};
MODULE_DEVICE_TABLE(pci, pciidlist);

806 807
static void i915_pci_remove(struct pci_dev *pdev)
{
808 809 810 811 812
	struct drm_device *dev;

	dev = pci_get_drvdata(pdev);
	if (!dev) /* driver load aborted, nothing to cleanup */
		return;
813 814

	i915_driver_unload(dev);
815
	drm_dev_put(dev);
816 817

	pci_set_drvdata(pdev, NULL);
818 819
}

820 821 822 823
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
	struct intel_device_info *intel_info =
		(struct intel_device_info *) ent->driver_data;
824
	int err;
825

826
	if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
827 828 829
		DRM_INFO("The driver support for your hardware in this kernel version is alpha quality\n"
			 "See CONFIG_DRM_I915_ALPHA_SUPPORT or i915.alpha_support module parameter\n"
			 "to enable support in this kernel version, or check for kernel updates.\n");
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
		return -ENODEV;
	}

	/* Only bind to function 0 of the device. Early generations
	 * used function 1 as a placeholder for multi-head. This causes
	 * us confusion instead, especially on the systems where both
	 * functions have the same PCI-ID!
	 */
	if (PCI_FUNC(pdev->devfn))
		return -ENODEV;

	/*
	 * apple-gmux is needed on dual GPU MacBook Pro
	 * to probe the panel if we're the inactive GPU.
	 */
	if (vga_switcheroo_client_probe_defer(pdev))
		return -EPROBE_DEFER;

848 849 850
	err = i915_driver_load(pdev, ent);
	if (err)
		return err;
851

852 853 854 855 856
	if (i915_inject_load_failure()) {
		i915_pci_remove(pdev);
		return -ENODEV;
	}

857 858 859 860 861
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
862

863
	return 0;
864 865
}

866
static struct pci_driver i915_pci_driver = {
867 868 869 870 871 872
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.driver.pm = &i915_pm_ops,
};
873 874 875 876

static int __init i915_init(void)
{
	bool use_kms = true;
877 878
	int err;

879 880 881
	err = i915_globals_init();
	if (err)
		return err;
882

883 884 885
	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
886 887 888 889 890 891 892

	/*
	 * Enable KMS by default, unless explicitly overriden by
	 * either the i915.modeset prarameter or by the
	 * vga_text_mode_force boot option.
	 */

893
	if (i915_modparams.modeset == 0)
894 895
		use_kms = false;

896
	if (vgacon_text_force() && i915_modparams.modeset == -1)
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913
		use_kms = false;

	if (!use_kms) {
		/* Silently fail loading to not upset userspace. */
		DRM_DEBUG_DRIVER("KMS disabled.\n");
		return 0;
	}

	return pci_register_driver(&i915_pci_driver);
}

static void __exit i915_exit(void)
{
	if (!i915_pci_driver.driver.owner)
		return;

	pci_unregister_driver(&i915_pci_driver);
914
	i915_globals_exit();
915 916 917 918 919 920 921 922 923 924
}

module_init(i915_init);
module_exit(i915_exit);

MODULE_AUTHOR("Tungsten Graphics, Inc.");
MODULE_AUTHOR("Intel Corporation");

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL and additional rights");