i915_pci.c 21.4 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
#include "i915_active.h"
30
#include "i915_drv.h"
31
#include "i915_selftest.h"
32

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

36
#define GEN_DEFAULT_PIPEOFFSETS \
37 38 39 40 41 42 43 44 45 46 47 48
	.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, \
	}
49 50

#define GEN_CHV_PIPEOFFSETS \
51 52 53 54 55 56 57 58 59 60
	.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, \
	}
61 62 63 64 65 66 67 68 69 70

#define CURSOR_OFFSETS \
	.cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }

#define IVB_CURSOR_OFFSETS \
	.cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }

#define BDW_COLORS \
	.color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
#define CHV_COLORS \
71 72 73 74
	.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 已提交
75
#define GLK_COLORS \
76 77 78 79
	.color = { .degamma_lut_size = 0, .gamma_lut_size = 1024, \
		   .degamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING | \
					DRM_COLOR_LUT_EQUAL_CHANNELS, \
	}
80

81
/* Keep in gen based order, and chronological order within a gen */
82 83 84 85

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

86
#define GEN2_FEATURES \
87 88
	GEN(2), \
	.num_pipes = 1, \
89 90
	.display.has_overlay = 1, \
	.display.overlay_needs_physical = 1, \
R
Rodrigo Vivi 已提交
91
	.display.has_gmch = 1, \
92
	.gpu_reset_clobbers_display = true, \
93
	.hws_needs_physical = 1, \
94
	.unfenced_needs_alignment = 1, \
95
	.ring_mask = RENDER_RING, \
96
	.has_snoop = true, \
97
	.has_coherent_ggtt = false, \
98
	GEN_DEFAULT_PIPEOFFSETS, \
99
	GEN_DEFAULT_PAGE_SIZES, \
100 101
	CURSOR_OFFSETS

102
static const struct intel_device_info intel_i830_info = {
103
	GEN2_FEATURES,
104
	PLATFORM(INTEL_I830),
105 106
	.is_mobile = 1,
	.display.cursor_needs_physical = 1,
107
	.num_pipes = 2, /* legal, last one wins */
108 109
};

110
static const struct intel_device_info intel_i845g_info = {
111
	GEN2_FEATURES,
112
	PLATFORM(INTEL_I845G),
113 114
};

115
static const struct intel_device_info intel_i85x_info = {
116
	GEN2_FEATURES,
117 118
	PLATFORM(INTEL_I85X),
	.is_mobile = 1,
119
	.num_pipes = 2, /* legal, last one wins */
120 121
	.display.cursor_needs_physical = 1,
	.display.has_fbc = 1,
122 123
};

124
static const struct intel_device_info intel_i865g_info = {
125
	GEN2_FEATURES,
126
	PLATFORM(INTEL_I865G),
127 128
};

129
#define GEN3_FEATURES \
130 131
	GEN(3), \
	.num_pipes = 2, \
R
Rodrigo Vivi 已提交
132
	.display.has_gmch = 1, \
133
	.gpu_reset_clobbers_display = true, \
134
	.ring_mask = RENDER_RING, \
135
	.has_snoop = true, \
136
	.has_coherent_ggtt = true, \
137
	GEN_DEFAULT_PIPEOFFSETS, \
138
	GEN_DEFAULT_PAGE_SIZES, \
139 140
	CURSOR_OFFSETS

141
static const struct intel_device_info intel_i915g_info = {
142
	GEN3_FEATURES,
143
	PLATFORM(INTEL_I915G),
144
	.has_coherent_ggtt = false,
145 146 147
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
148
	.hws_needs_physical = 1,
149
	.unfenced_needs_alignment = 1,
150
};
151

152
static const struct intel_device_info intel_i915gm_info = {
153
	GEN3_FEATURES,
154
	PLATFORM(INTEL_I915GM),
155
	.is_mobile = 1,
156 157 158 159 160
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
	.display.supports_tv = 1,
	.display.has_fbc = 1,
161
	.hws_needs_physical = 1,
162
	.unfenced_needs_alignment = 1,
163
};
164

165
static const struct intel_device_info intel_i945g_info = {
166
	GEN3_FEATURES,
167
	PLATFORM(INTEL_I945G),
168 169 170 171
	.display.has_hotplug = 1,
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
172
	.hws_needs_physical = 1,
173
	.unfenced_needs_alignment = 1,
174
};
175

176
static const struct intel_device_info intel_i945gm_info = {
177
	GEN3_FEATURES,
178 179
	PLATFORM(INTEL_I945GM),
	.is_mobile = 1,
180 181 182 183 184 185
	.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,
186
	.hws_needs_physical = 1,
187
	.unfenced_needs_alignment = 1,
188 189
};

190
static const struct intel_device_info intel_g33_info = {
191
	GEN3_FEATURES,
192
	PLATFORM(INTEL_G33),
193 194
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
195 196
};

197
static const struct intel_device_info intel_pineview_info = {
198
	GEN3_FEATURES,
199 200
	PLATFORM(INTEL_PINEVIEW),
	.is_mobile = 1,
201 202
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
203 204
};

205
#define GEN4_FEATURES \
206 207
	GEN(4), \
	.num_pipes = 2, \
208
	.display.has_hotplug = 1, \
R
Rodrigo Vivi 已提交
209
	.display.has_gmch = 1, \
210
	.gpu_reset_clobbers_display = true, \
211
	.ring_mask = RENDER_RING, \
212
	.has_snoop = true, \
213
	.has_coherent_ggtt = true, \
214
	GEN_DEFAULT_PIPEOFFSETS, \
215
	GEN_DEFAULT_PAGE_SIZES, \
216 217
	CURSOR_OFFSETS

218
static const struct intel_device_info intel_i965g_info = {
219
	GEN4_FEATURES,
220
	PLATFORM(INTEL_I965G),
221
	.display.has_overlay = 1,
222
	.hws_needs_physical = 1,
223
	.has_snoop = false,
224 225
};

226
static const struct intel_device_info intel_i965gm_info = {
227
	GEN4_FEATURES,
228
	PLATFORM(INTEL_I965GM),
229 230 231 232
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.has_overlay = 1,
	.display.supports_tv = 1,
233
	.hws_needs_physical = 1,
234
	.has_snoop = false,
235 236
};

237
static const struct intel_device_info intel_g45_info = {
238
	GEN4_FEATURES,
239
	PLATFORM(INTEL_G45),
240
	.ring_mask = RENDER_RING | BSD_RING,
241
	.gpu_reset_clobbers_display = false,
242 243
};

244
static const struct intel_device_info intel_gm45_info = {
245
	GEN4_FEATURES,
246
	PLATFORM(INTEL_GM45),
247 248 249
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.supports_tv = 1,
250
	.ring_mask = RENDER_RING | BSD_RING,
251
	.gpu_reset_clobbers_display = false,
252 253
};

254
#define GEN5_FEATURES \
255 256
	GEN(5), \
	.num_pipes = 2, \
257
	.display.has_hotplug = 1, \
258
	.ring_mask = RENDER_RING | BSD_RING, \
259
	.has_snoop = true, \
260
	.has_coherent_ggtt = true, \
261 262
	/* ilk does support rc6, but we do not implement [power] contexts */ \
	.has_rc6 = 0, \
263
	GEN_DEFAULT_PIPEOFFSETS, \
264
	GEN_DEFAULT_PAGE_SIZES, \
265 266
	CURSOR_OFFSETS

267
static const struct intel_device_info intel_ironlake_d_info = {
268
	GEN5_FEATURES,
269
	PLATFORM(INTEL_IRONLAKE),
270 271
};

272
static const struct intel_device_info intel_ironlake_m_info = {
273
	GEN5_FEATURES,
274
	PLATFORM(INTEL_IRONLAKE),
275 276
	.is_mobile = 1,
	.display.has_fbc = 1,
277 278
};

279
#define GEN6_FEATURES \
280 281
	GEN(6), \
	.num_pipes = 2, \
282 283
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
284
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
285
	.has_coherent_ggtt = true, \
286
	.has_llc = 1, \
287
	.has_rc6 = 1, \
288
	.has_rc6p = 1, \
289
	.ppgtt = INTEL_PPGTT_ALIASING, \
290
	GEN_DEFAULT_PIPEOFFSETS, \
291
	GEN_DEFAULT_PAGE_SIZES, \
292 293
	CURSOR_OFFSETS

294 295
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
296
	PLATFORM(INTEL_SANDYBRIDGE)
297

298
static const struct intel_device_info intel_sandybridge_d_gt1_info = {
299 300
	SNB_D_PLATFORM,
	.gt = 1,
301 302
};

303
static const struct intel_device_info intel_sandybridge_d_gt2_info = {
304 305 306 307 308 309
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
310
	PLATFORM(INTEL_SANDYBRIDGE), \
311 312 313
	.is_mobile = 1


314
static const struct intel_device_info intel_sandybridge_m_gt1_info = {
315 316 317 318
	SNB_M_PLATFORM,
	.gt = 1,
};

319
static const struct intel_device_info intel_sandybridge_m_gt2_info = {
320 321
	SNB_M_PLATFORM,
	.gt = 2,
322 323 324
};

#define GEN7_FEATURES  \
325 326
	GEN(7), \
	.num_pipes = 3, \
327 328
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
329
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
330
	.has_coherent_ggtt = true, \
331
	.has_llc = 1, \
332
	.has_rc6 = 1, \
333
	.has_rc6p = 1, \
334
	.ppgtt = INTEL_PPGTT_FULL, \
335
	GEN_DEFAULT_PIPEOFFSETS, \
336
	GEN_DEFAULT_PAGE_SIZES, \
337 338
	IVB_CURSOR_OFFSETS

339 340
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
341
	PLATFORM(INTEL_IVYBRIDGE), \
342 343
	.has_l3_dpf = 1

344
static const struct intel_device_info intel_ivybridge_d_gt1_info = {
345 346
	IVB_D_PLATFORM,
	.gt = 1,
347 348
};

349
static const struct intel_device_info intel_ivybridge_d_gt2_info = {
350 351 352 353 354 355
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
356
	PLATFORM(INTEL_IVYBRIDGE), \
357 358 359
	.is_mobile = 1, \
	.has_l3_dpf = 1

360
static const struct intel_device_info intel_ivybridge_m_gt1_info = {
361 362 363 364
	IVB_M_PLATFORM,
	.gt = 1,
};

365
static const struct intel_device_info intel_ivybridge_m_gt2_info = {
366 367
	IVB_M_PLATFORM,
	.gt = 2,
368 369
};

370
static const struct intel_device_info intel_ivybridge_q_info = {
371
	GEN7_FEATURES,
372
	PLATFORM(INTEL_IVYBRIDGE),
373
	.gt = 2,
374
	.num_pipes = 0, /* legal, last one wins */
375
	.has_l3_dpf = 1,
376 377
};

378
static const struct intel_device_info intel_valleyview_info = {
379
	PLATFORM(INTEL_VALLEYVIEW),
380
	GEN(7),
381 382 383 384
	.is_lp = 1,
	.num_pipes = 2,
	.has_runtime_pm = 1,
	.has_rc6 = 1,
R
Rodrigo Vivi 已提交
385
	.display.has_gmch = 1,
386
	.display.has_hotplug = 1,
387
	.ppgtt = INTEL_PPGTT_FULL,
388
	.has_snoop = true,
389
	.has_coherent_ggtt = false,
390 391
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
	.display_mmio_offset = VLV_DISPLAY_BASE,
392
	GEN_DEFAULT_PAGE_SIZES,
393 394
	GEN_DEFAULT_PIPEOFFSETS,
	CURSOR_OFFSETS
395 396
};

397
#define G75_FEATURES  \
398 399
	GEN7_FEATURES, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
400
	.display.has_ddi = 1, \
401
	.has_fpga_dbg = 1, \
402 403
	.display.has_psr = 1, \
	.display.has_dp_mst = 1, \
404
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
405
	.has_runtime_pm = 1
406

407
#define HSW_PLATFORM \
408
	G75_FEATURES, \
409
	PLATFORM(INTEL_HASWELL), \
410 411
	.has_l3_dpf = 1

412
static const struct intel_device_info intel_haswell_gt1_info = {
413 414 415 416
	HSW_PLATFORM,
	.gt = 1,
};

417
static const struct intel_device_info intel_haswell_gt2_info = {
418 419 420 421
	HSW_PLATFORM,
	.gt = 2,
};

422
static const struct intel_device_info intel_haswell_gt3_info = {
423 424
	HSW_PLATFORM,
	.gt = 3,
425 426
};

427 428
#define GEN8_FEATURES \
	G75_FEATURES, \
429
	GEN(8), \
430
	BDW_COLORS, \
431 432
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_2M, \
433
	.has_logical_ring_contexts = 1, \
434
	.ppgtt = INTEL_PPGTT_FULL_4LVL, \
435 436
	.has_64bit_reloc = 1, \
	.has_reset_engine = 1
437

438
#define BDW_PLATFORM \
439
	GEN8_FEATURES, \
440
	PLATFORM(INTEL_BROADWELL)
441

442
static const struct intel_device_info intel_broadwell_gt1_info = {
443 444 445 446
	BDW_PLATFORM,
	.gt = 1,
};

447
static const struct intel_device_info intel_broadwell_gt2_info = {
448
	BDW_PLATFORM,
449 450 451
	.gt = 2,
};

452
static const struct intel_device_info intel_broadwell_rsvd_info = {
453 454 455 456 457
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
458 459
};

460
static const struct intel_device_info intel_broadwell_gt3_info = {
461
	BDW_PLATFORM,
462
	.gt = 3,
463 464 465
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

466
static const struct intel_device_info intel_cherryview_info = {
467
	PLATFORM(INTEL_CHERRYVIEW),
468 469
	GEN(8),
	.num_pipes = 3,
470
	.display.has_hotplug = 1,
471
	.is_lp = 1,
472
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
473
	.has_64bit_reloc = 1,
474
	.has_runtime_pm = 1,
475
	.has_rc6 = 1,
476
	.has_logical_ring_contexts = 1,
R
Rodrigo Vivi 已提交
477
	.display.has_gmch = 1,
478
	.ppgtt = INTEL_PPGTT_FULL,
479
	.has_reset_engine = 1,
480
	.has_snoop = true,
481
	.has_coherent_ggtt = false,
482
	.display_mmio_offset = VLV_DISPLAY_BASE,
483
	GEN_DEFAULT_PAGE_SIZES,
484 485 486 487 488
	GEN_CHV_PIPEOFFSETS,
	CURSOR_OFFSETS,
	CHV_COLORS,
};

489
#define GEN9_DEFAULT_PAGE_SIZES \
490
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
491 492
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M
493

494 495
#define GEN9_FEATURES \
	GEN8_FEATURES, \
496
	GEN(9), \
497
	GEN9_DEFAULT_PAGE_SIZES, \
C
Chris Wilson 已提交
498
	.has_logical_ring_preemption = 1, \
499
	.display.has_csr = 1, \
500
	.has_guc = 1, \
501
	.display.has_ipc = 1, \
502 503
	.ddb_size = 896

504 505
#define SKL_PLATFORM \
	GEN9_FEATURES, \
506
	/* Display WA #0477 WaDisableIPC: skl */ \
507
	.display.has_ipc = 0, \
508
	PLATFORM(INTEL_SKYLAKE)
509

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

515
static const struct intel_device_info intel_skylake_gt2_info = {
516
	SKL_PLATFORM,
517 518 519 520 521 522 523 524
	.gt = 2,
};

#define SKL_GT3_PLUS_PLATFORM \
	SKL_PLATFORM, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING


525
static const struct intel_device_info intel_skylake_gt3_info = {
526 527 528 529
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

530
static const struct intel_device_info intel_skylake_gt4_info = {
531 532
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
533 534
};

535
#define GEN9_LP_FEATURES \
536
	GEN(9), \
537
	.is_lp = 1, \
538
	.display.has_hotplug = 1, \
539 540 541
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
	.num_pipes = 3, \
	.has_64bit_reloc = 1, \
542
	.display.has_ddi = 1, \
543
	.has_fpga_dbg = 1, \
544 545
	.display.has_fbc = 1, \
	.display.has_psr = 1, \
546
	.has_runtime_pm = 1, \
547
	.display.has_csr = 1, \
548
	.has_rc6 = 1, \
549
	.display.has_dp_mst = 1, \
550
	.has_logical_ring_contexts = 1, \
C
Chris Wilson 已提交
551
	.has_logical_ring_preemption = 1, \
552
	.has_guc = 1, \
553
	.ppgtt = INTEL_PPGTT_FULL_4LVL, \
554
	.has_reset_engine = 1, \
555
	.has_snoop = true, \
556
	.has_coherent_ggtt = false, \
557
	.display.has_ipc = 1, \
558
	GEN9_DEFAULT_PAGE_SIZES, \
559 560 561 562
	GEN_DEFAULT_PIPEOFFSETS, \
	IVB_CURSOR_OFFSETS, \
	BDW_COLORS

563
static const struct intel_device_info intel_broxton_info = {
564
	GEN9_LP_FEATURES,
565
	PLATFORM(INTEL_BROXTON),
566
	.ddb_size = 512,
567 568
};

569
static const struct intel_device_info intel_geminilake_info = {
570
	GEN9_LP_FEATURES,
571
	PLATFORM(INTEL_GEMINILAKE),
572
	.ddb_size = 1024,
R
Rodrigo Vivi 已提交
573
	GLK_COLORS,
574 575
};

576
#define KBL_PLATFORM \
577
	GEN9_FEATURES, \
578
	PLATFORM(INTEL_KABYLAKE)
579

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

585
static const struct intel_device_info intel_kabylake_gt2_info = {
586 587
	KBL_PLATFORM,
	.gt = 2,
588 589
};

590
static const struct intel_device_info intel_kabylake_gt3_info = {
591
	KBL_PLATFORM,
592
	.gt = 3,
593 594 595
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

596
#define CFL_PLATFORM \
597
	GEN9_FEATURES, \
598
	PLATFORM(INTEL_COFFEELAKE)
599

600
static const struct intel_device_info intel_coffeelake_gt1_info = {
601 602 603 604
	CFL_PLATFORM,
	.gt = 1,
};

605
static const struct intel_device_info intel_coffeelake_gt2_info = {
606
	CFL_PLATFORM,
607
	.gt = 2,
608 609
};

610
static const struct intel_device_info intel_coffeelake_gt3_info = {
611
	CFL_PLATFORM,
612
	.gt = 3,
613 614 615
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

616 617
#define GEN10_FEATURES \
	GEN9_FEATURES, \
618
	GEN(10), \
619
	.ddb_size = 1024, \
620
	.has_coherent_ggtt = false, \
R
Rodrigo Vivi 已提交
621
	GLK_COLORS
622

623
static const struct intel_device_info intel_cannonlake_info = {
624
	GEN10_FEATURES,
625
	PLATFORM(INTEL_CANNONLAKE),
626
	.gt = 2,
627 628
};

629 630
#define GEN11_FEATURES \
	GEN10_FEATURES, \
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
	.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, \
	}, \
647
	GEN(11), \
648
	.ddb_size = 2048, \
649
	.has_logical_ring_elsq = 1
650

651
static const struct intel_device_info intel_icelake_11_info = {
652
	GEN11_FEATURES,
653
	PLATFORM(INTEL_ICELAKE),
654
	.is_alpha_support = 1,
655
	.ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING,
656 657
};

658
#undef GEN
659
#undef PLATFORM
660

661 662 663 664 665 666 667 668
/*
 * 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),
669
	INTEL_I845G_IDS(&intel_i845g_info),
670 671 672 673 674 675 676 677 678 679 680 681 682 683
	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),
684 685 686 687
	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),
688
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
689 690 691 692 693 694 695
	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),
696
	INTEL_VLV_IDS(&intel_valleyview_info),
697 698
	INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
	INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
699
	INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
700
	INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
701
	INTEL_CHV_IDS(&intel_cherryview_info),
702 703
	INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
	INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
704
	INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
705
	INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
706
	INTEL_BXT_IDS(&intel_broxton_info),
707
	INTEL_GLK_IDS(&intel_geminilake_info),
708 709
	INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
	INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
710 711
	INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
	INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
712
	INTEL_AML_KBL_GT2_IDS(&intel_kabylake_gt2_info),
713 714
	INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
715
	INTEL_CFL_H_GT1_IDS(&intel_coffeelake_gt1_info),
716
	INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
717
	INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
718
	INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
719 720
	INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
721
	INTEL_AML_CFL_GT2_IDS(&intel_coffeelake_gt2_info),
722
	INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
723
	INTEL_CNL_IDS(&intel_cannonlake_info),
P
Paulo Zanoni 已提交
724
	INTEL_ICL_11_IDS(&intel_icelake_11_info),
725 726 727 728
	{0, 0, 0}
};
MODULE_DEVICE_TABLE(pci, pciidlist);

729 730
static void i915_pci_remove(struct pci_dev *pdev)
{
731 732 733 734 735
	struct drm_device *dev;

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

	i915_driver_unload(dev);
738
	drm_dev_put(dev);
739 740

	pci_set_drvdata(pdev, NULL);
741 742
}

743 744 745 746
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;
747
	int err;
748

749
	if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
750 751 752
		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");
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
		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;

771 772 773
	err = i915_driver_load(pdev, ent);
	if (err)
		return err;
774

775 776 777 778 779
	if (i915_inject_load_failure()) {
		i915_pci_remove(pdev);
		return -ENODEV;
	}

780 781 782 783 784
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
785

786
	return 0;
787 788
}

789
static struct pci_driver i915_pci_driver = {
790 791 792 793 794 795
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.driver.pm = &i915_pm_ops,
};
796 797 798 799

static int __init i915_init(void)
{
	bool use_kms = true;
800 801
	int err;

802 803
	i915_global_active_init();

804 805 806
	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
807 808 809 810 811 812 813

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

814
	if (i915_modparams.modeset == 0)
815 816
		use_kms = false;

817
	if (vgacon_text_force() && i915_modparams.modeset == -1)
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
		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);
835
	i915_global_active_exit();
836 837 838 839 840 841 842 843 844 845
}

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");