i915_pci.c 19.9 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 29
#include <linux/vgaarb.h>
#include <linux/vga_switcheroo.h>

#include "i915_drv.h"
30
#include "i915_selftest.h"
31

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

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#define GEN_DEFAULT_PIPEOFFSETS \
	.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
			  PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
	.trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
			   TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
	.palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }

#define GEN_CHV_PIPEOFFSETS \
	.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
			  CHV_PIPE_C_OFFSET }, \
	.trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
			   CHV_TRANSCODER_C_OFFSET, }, \
	.palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
			     CHV_PALETTE_C_OFFSET }

#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 \
	.color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
R
Rodrigo Vivi 已提交
60 61
#define GLK_COLORS \
	.color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
62

63
/* Keep in gen based order, and chronological order within a gen */
64 65 66 67

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

68
#define GEN2_FEATURES \
69 70
	GEN(2), \
	.num_pipes = 1, \
71
	.has_overlay = 1, .overlay_needs_physical = 1, \
72
	.has_gmch_display = 1, \
73
	.hws_needs_physical = 1, \
74
	.unfenced_needs_alignment = 1, \
75
	.ring_mask = RENDER_RING, \
76
	.has_snoop = true, \
77
	.has_coherent_ggtt = false, \
78
	GEN_DEFAULT_PIPEOFFSETS, \
79
	GEN_DEFAULT_PAGE_SIZES, \
80 81
	CURSOR_OFFSETS

82
static const struct intel_device_info intel_i830_info = {
83
	GEN2_FEATURES,
84
	PLATFORM(INTEL_I830),
85 86
	.is_mobile = 1, .cursor_needs_physical = 1,
	.num_pipes = 2, /* legal, last one wins */
87 88
};

89
static const struct intel_device_info intel_i845g_info = {
90
	GEN2_FEATURES,
91
	PLATFORM(INTEL_I845G),
92 93
};

94
static const struct intel_device_info intel_i85x_info = {
95
	GEN2_FEATURES,
96 97
	PLATFORM(INTEL_I85X),
	.is_mobile = 1,
98
	.num_pipes = 2, /* legal, last one wins */
99 100 101 102
	.cursor_needs_physical = 1,
	.has_fbc = 1,
};

103
static const struct intel_device_info intel_i865g_info = {
104
	GEN2_FEATURES,
105
	PLATFORM(INTEL_I865G),
106 107
};

108
#define GEN3_FEATURES \
109 110
	GEN(3), \
	.num_pipes = 2, \
111
	.has_gmch_display = 1, \
112
	.ring_mask = RENDER_RING, \
113
	.has_snoop = true, \
114
	.has_coherent_ggtt = true, \
115
	GEN_DEFAULT_PIPEOFFSETS, \
116
	GEN_DEFAULT_PAGE_SIZES, \
117 118
	CURSOR_OFFSETS

119
static const struct intel_device_info intel_i915g_info = {
120
	GEN3_FEATURES,
121
	PLATFORM(INTEL_I915G),
122
	.has_coherent_ggtt = false,
123
	.cursor_needs_physical = 1,
124
	.has_overlay = 1, .overlay_needs_physical = 1,
125
	.hws_needs_physical = 1,
126
	.unfenced_needs_alignment = 1,
127
};
128

129
static const struct intel_device_info intel_i915gm_info = {
130
	GEN3_FEATURES,
131
	PLATFORM(INTEL_I915GM),
132
	.is_mobile = 1,
133 134 135 136
	.cursor_needs_physical = 1,
	.has_overlay = 1, .overlay_needs_physical = 1,
	.supports_tv = 1,
	.has_fbc = 1,
137
	.hws_needs_physical = 1,
138
	.unfenced_needs_alignment = 1,
139
};
140

141
static const struct intel_device_info intel_i945g_info = {
142
	GEN3_FEATURES,
143
	PLATFORM(INTEL_I945G),
144
	.has_hotplug = 1, .cursor_needs_physical = 1,
145
	.has_overlay = 1, .overlay_needs_physical = 1,
146
	.hws_needs_physical = 1,
147
	.unfenced_needs_alignment = 1,
148
};
149

150
static const struct intel_device_info intel_i945gm_info = {
151
	GEN3_FEATURES,
152 153
	PLATFORM(INTEL_I945GM),
	.is_mobile = 1,
154 155 156 157
	.has_hotplug = 1, .cursor_needs_physical = 1,
	.has_overlay = 1, .overlay_needs_physical = 1,
	.supports_tv = 1,
	.has_fbc = 1,
158
	.hws_needs_physical = 1,
159
	.unfenced_needs_alignment = 1,
160 161
};

162
static const struct intel_device_info intel_g33_info = {
163
	GEN3_FEATURES,
164
	PLATFORM(INTEL_G33),
165 166 167 168
	.has_hotplug = 1,
	.has_overlay = 1,
};

169
static const struct intel_device_info intel_pineview_info = {
170
	GEN3_FEATURES,
171 172
	PLATFORM(INTEL_PINEVIEW),
	.is_mobile = 1,
173 174 175 176
	.has_hotplug = 1,
	.has_overlay = 1,
};

177
#define GEN4_FEATURES \
178 179
	GEN(4), \
	.num_pipes = 2, \
180
	.has_hotplug = 1, \
181
	.has_gmch_display = 1, \
182
	.ring_mask = RENDER_RING, \
183
	.has_snoop = true, \
184
	.has_coherent_ggtt = true, \
185
	GEN_DEFAULT_PIPEOFFSETS, \
186
	GEN_DEFAULT_PAGE_SIZES, \
187 188
	CURSOR_OFFSETS

189
static const struct intel_device_info intel_i965g_info = {
190
	GEN4_FEATURES,
191
	PLATFORM(INTEL_I965G),
192
	.has_overlay = 1,
193
	.hws_needs_physical = 1,
194
	.has_snoop = false,
195 196
};

197
static const struct intel_device_info intel_i965gm_info = {
198
	GEN4_FEATURES,
199
	PLATFORM(INTEL_I965GM),
200
	.is_mobile = 1, .has_fbc = 1,
201 202
	.has_overlay = 1,
	.supports_tv = 1,
203
	.hws_needs_physical = 1,
204
	.has_snoop = false,
205 206
};

207
static const struct intel_device_info intel_g45_info = {
208
	GEN4_FEATURES,
209
	PLATFORM(INTEL_G45),
210 211 212
	.ring_mask = RENDER_RING | BSD_RING,
};

213
static const struct intel_device_info intel_gm45_info = {
214
	GEN4_FEATURES,
215
	PLATFORM(INTEL_GM45),
216
	.is_mobile = 1, .has_fbc = 1,
217 218 219 220
	.supports_tv = 1,
	.ring_mask = RENDER_RING | BSD_RING,
};

221
#define GEN5_FEATURES \
222 223
	GEN(5), \
	.num_pipes = 2, \
224
	.has_hotplug = 1, \
225
	.ring_mask = RENDER_RING | BSD_RING, \
226
	.has_snoop = true, \
227
	.has_coherent_ggtt = true, \
228 229
	/* ilk does support rc6, but we do not implement [power] contexts */ \
	.has_rc6 = 0, \
230
	GEN_DEFAULT_PIPEOFFSETS, \
231
	GEN_DEFAULT_PAGE_SIZES, \
232 233
	CURSOR_OFFSETS

234
static const struct intel_device_info intel_ironlake_d_info = {
235
	GEN5_FEATURES,
236
	PLATFORM(INTEL_IRONLAKE),
237 238
};

239
static const struct intel_device_info intel_ironlake_m_info = {
240
	GEN5_FEATURES,
241
	PLATFORM(INTEL_IRONLAKE),
242
	.is_mobile = 1, .has_fbc = 1,
243 244
};

245
#define GEN6_FEATURES \
246 247
	GEN(6), \
	.num_pipes = 2, \
248
	.has_hotplug = 1, \
249 250
	.has_fbc = 1, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
251
	.has_coherent_ggtt = true, \
252
	.has_llc = 1, \
253
	.has_rc6 = 1, \
254
	.has_rc6p = 1, \
255
	.has_aliasing_ppgtt = 1, \
256
	GEN_DEFAULT_PIPEOFFSETS, \
257
	GEN_DEFAULT_PAGE_SIZES, \
258 259
	CURSOR_OFFSETS

260 261
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
262
	PLATFORM(INTEL_SANDYBRIDGE)
263

264
static const struct intel_device_info intel_sandybridge_d_gt1_info = {
265 266
	SNB_D_PLATFORM,
	.gt = 1,
267 268
};

269
static const struct intel_device_info intel_sandybridge_d_gt2_info = {
270 271 272 273 274 275
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
276
	PLATFORM(INTEL_SANDYBRIDGE), \
277 278 279
	.is_mobile = 1


280
static const struct intel_device_info intel_sandybridge_m_gt1_info = {
281 282 283 284
	SNB_M_PLATFORM,
	.gt = 1,
};

285
static const struct intel_device_info intel_sandybridge_m_gt2_info = {
286 287
	SNB_M_PLATFORM,
	.gt = 2,
288 289 290
};

#define GEN7_FEATURES  \
291 292
	GEN(7), \
	.num_pipes = 3, \
293
	.has_hotplug = 1, \
294 295
	.has_fbc = 1, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
296
	.has_coherent_ggtt = true, \
297
	.has_llc = 1, \
298
	.has_rc6 = 1, \
299
	.has_rc6p = 1, \
300 301
	.has_aliasing_ppgtt = 1, \
	.has_full_ppgtt = 1, \
302
	GEN_DEFAULT_PIPEOFFSETS, \
303
	GEN_DEFAULT_PAGE_SIZES, \
304 305
	IVB_CURSOR_OFFSETS

306 307
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
308
	PLATFORM(INTEL_IVYBRIDGE), \
309 310
	.has_l3_dpf = 1

311
static const struct intel_device_info intel_ivybridge_d_gt1_info = {
312 313
	IVB_D_PLATFORM,
	.gt = 1,
314 315
};

316
static const struct intel_device_info intel_ivybridge_d_gt2_info = {
317 318 319 320 321 322
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
323
	PLATFORM(INTEL_IVYBRIDGE), \
324 325 326
	.is_mobile = 1, \
	.has_l3_dpf = 1

327
static const struct intel_device_info intel_ivybridge_m_gt1_info = {
328 329 330 331
	IVB_M_PLATFORM,
	.gt = 1,
};

332
static const struct intel_device_info intel_ivybridge_m_gt2_info = {
333 334
	IVB_M_PLATFORM,
	.gt = 2,
335 336
};

337
static const struct intel_device_info intel_ivybridge_q_info = {
338
	GEN7_FEATURES,
339
	PLATFORM(INTEL_IVYBRIDGE),
340
	.gt = 2,
341
	.num_pipes = 0, /* legal, last one wins */
342
	.has_l3_dpf = 1,
343 344
};

345
static const struct intel_device_info intel_valleyview_info = {
346
	PLATFORM(INTEL_VALLEYVIEW),
347
	GEN(7),
348 349 350 351 352 353 354 355
	.is_lp = 1,
	.num_pipes = 2,
	.has_runtime_pm = 1,
	.has_rc6 = 1,
	.has_gmch_display = 1,
	.has_hotplug = 1,
	.has_aliasing_ppgtt = 1,
	.has_full_ppgtt = 1,
356
	.has_snoop = true,
357
	.has_coherent_ggtt = false,
358 359
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
	.display_mmio_offset = VLV_DISPLAY_BASE,
360
	GEN_DEFAULT_PAGE_SIZES,
361 362
	GEN_DEFAULT_PIPEOFFSETS,
	CURSOR_OFFSETS
363 364
};

365
#define G75_FEATURES  \
366 367 368
	GEN7_FEATURES, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
	.has_ddi = 1, \
369
	.has_fpga_dbg = 1, \
370
	.has_psr = 1, \
371
	.has_resource_streamer = 1, \
372
	.has_dp_mst = 1, \
373
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
374
	.has_runtime_pm = 1
375

376
#define HSW_PLATFORM \
377
	G75_FEATURES, \
378
	PLATFORM(INTEL_HASWELL), \
379 380
	.has_l3_dpf = 1

381
static const struct intel_device_info intel_haswell_gt1_info = {
382 383 384 385
	HSW_PLATFORM,
	.gt = 1,
};

386
static const struct intel_device_info intel_haswell_gt2_info = {
387 388 389 390
	HSW_PLATFORM,
	.gt = 2,
};

391
static const struct intel_device_info intel_haswell_gt3_info = {
392 393
	HSW_PLATFORM,
	.gt = 3,
394 395
};

396 397
#define GEN8_FEATURES \
	G75_FEATURES, \
398
	GEN(8), \
399
	BDW_COLORS, \
400 401
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_2M, \
402
	.has_logical_ring_contexts = 1, \
403
	.has_full_48bit_ppgtt = 1, \
404 405
	.has_64bit_reloc = 1, \
	.has_reset_engine = 1
406

407
#define BDW_PLATFORM \
408
	GEN8_FEATURES, \
409
	PLATFORM(INTEL_BROADWELL)
410

411
static const struct intel_device_info intel_broadwell_gt1_info = {
412 413 414 415
	BDW_PLATFORM,
	.gt = 1,
};

416
static const struct intel_device_info intel_broadwell_gt2_info = {
417
	BDW_PLATFORM,
418 419 420
	.gt = 2,
};

421
static const struct intel_device_info intel_broadwell_rsvd_info = {
422 423 424 425 426
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
427 428
};

429
static const struct intel_device_info intel_broadwell_gt3_info = {
430
	BDW_PLATFORM,
431
	.gt = 3,
432 433 434
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

435
static const struct intel_device_info intel_cherryview_info = {
436
	PLATFORM(INTEL_CHERRYVIEW),
437 438
	GEN(8),
	.num_pipes = 3,
439
	.has_hotplug = 1,
440
	.is_lp = 1,
441
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
442
	.has_64bit_reloc = 1,
443
	.has_runtime_pm = 1,
444
	.has_resource_streamer = 1,
445
	.has_rc6 = 1,
446
	.has_logical_ring_contexts = 1,
447
	.has_gmch_display = 1,
448 449
	.has_aliasing_ppgtt = 1,
	.has_full_ppgtt = 1,
450
	.has_reset_engine = 1,
451
	.has_snoop = true,
452
	.has_coherent_ggtt = false,
453
	.display_mmio_offset = VLV_DISPLAY_BASE,
454
	GEN_DEFAULT_PAGE_SIZES,
455 456 457 458 459
	GEN_CHV_PIPEOFFSETS,
	CURSOR_OFFSETS,
	CHV_COLORS,
};

460
#define GEN9_DEFAULT_PAGE_SIZES \
461
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
462 463
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M
464

465 466
#define GEN9_FEATURES \
	GEN8_FEATURES, \
467
	GEN(9), \
468
	GEN9_DEFAULT_PAGE_SIZES, \
C
Chris Wilson 已提交
469
	.has_logical_ring_preemption = 1, \
470 471
	.has_csr = 1, \
	.has_guc = 1, \
472
	.has_ipc = 1, \
473 474
	.ddb_size = 896

475 476
#define SKL_PLATFORM \
	GEN9_FEATURES, \
477
	PLATFORM(INTEL_SKYLAKE)
478

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

484
static const struct intel_device_info intel_skylake_gt2_info = {
485
	SKL_PLATFORM,
486 487 488 489 490 491 492 493
	.gt = 2,
};

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


494
static const struct intel_device_info intel_skylake_gt3_info = {
495 496 497 498
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

499
static const struct intel_device_info intel_skylake_gt4_info = {
500 501
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
502 503
};

504
#define GEN9_LP_FEATURES \
505
	GEN(9), \
506
	.is_lp = 1, \
507 508 509 510 511 512 513
	.has_hotplug = 1, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
	.num_pipes = 3, \
	.has_64bit_reloc = 1, \
	.has_ddi = 1, \
	.has_fpga_dbg = 1, \
	.has_fbc = 1, \
514
	.has_psr = 1, \
515 516 517 518 519 520 521
	.has_runtime_pm = 1, \
	.has_pooled_eu = 0, \
	.has_csr = 1, \
	.has_resource_streamer = 1, \
	.has_rc6 = 1, \
	.has_dp_mst = 1, \
	.has_logical_ring_contexts = 1, \
C
Chris Wilson 已提交
522
	.has_logical_ring_preemption = 1, \
523
	.has_guc = 1, \
524 525 526
	.has_aliasing_ppgtt = 1, \
	.has_full_ppgtt = 1, \
	.has_full_48bit_ppgtt = 1, \
527
	.has_reset_engine = 1, \
528
	.has_snoop = true, \
529
	.has_coherent_ggtt = false, \
530
	.has_ipc = 1, \
531
	GEN9_DEFAULT_PAGE_SIZES, \
532 533 534 535
	GEN_DEFAULT_PIPEOFFSETS, \
	IVB_CURSOR_OFFSETS, \
	BDW_COLORS

536
static const struct intel_device_info intel_broxton_info = {
537
	GEN9_LP_FEATURES,
538
	PLATFORM(INTEL_BROXTON),
539
	.ddb_size = 512,
540 541
};

542
static const struct intel_device_info intel_geminilake_info = {
543
	GEN9_LP_FEATURES,
544
	PLATFORM(INTEL_GEMINILAKE),
545
	.ddb_size = 1024,
R
Rodrigo Vivi 已提交
546
	GLK_COLORS,
547 548
};

549
#define KBL_PLATFORM \
550
	GEN9_FEATURES, \
551
	PLATFORM(INTEL_KABYLAKE)
552

553
static const struct intel_device_info intel_kabylake_gt1_info = {
554
	KBL_PLATFORM,
555 556 557
	.gt = 1,
};

558
static const struct intel_device_info intel_kabylake_gt2_info = {
559 560
	KBL_PLATFORM,
	.gt = 2,
561 562
};

563
static const struct intel_device_info intel_kabylake_gt3_info = {
564
	KBL_PLATFORM,
565
	.gt = 3,
566 567 568
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

569
#define CFL_PLATFORM \
570
	GEN9_FEATURES, \
571
	PLATFORM(INTEL_COFFEELAKE)
572

573
static const struct intel_device_info intel_coffeelake_gt1_info = {
574 575 576 577
	CFL_PLATFORM,
	.gt = 1,
};

578
static const struct intel_device_info intel_coffeelake_gt2_info = {
579
	CFL_PLATFORM,
580
	.gt = 2,
581 582
};

583
static const struct intel_device_info intel_coffeelake_gt3_info = {
584
	CFL_PLATFORM,
585
	.gt = 3,
586 587 588
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

589 590
#define GEN10_FEATURES \
	GEN9_FEATURES, \
591
	GEN(10), \
592
	.ddb_size = 1024, \
593
	.has_coherent_ggtt = false, \
R
Rodrigo Vivi 已提交
594
	GLK_COLORS
595

596
static const struct intel_device_info intel_cannonlake_info = {
597
	GEN10_FEATURES,
598
	PLATFORM(INTEL_CANNONLAKE),
599
	.gt = 2,
600 601
};

602 603
#define GEN11_FEATURES \
	GEN10_FEATURES, \
604
	GEN(11), \
605
	.ddb_size = 2048, \
606 607
	.has_csr = 0, \
	.has_logical_ring_elsq = 1
608

609
static const struct intel_device_info intel_icelake_11_info = {
610
	GEN11_FEATURES,
611
	PLATFORM(INTEL_ICELAKE),
612 613
	.is_alpha_support = 1,
	.has_resource_streamer = 0,
614
	.ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING,
615 616
};

617
#undef GEN
618
#undef PLATFORM
619

620 621 622 623 624 625 626 627
/*
 * 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),
628
	INTEL_I845G_IDS(&intel_i845g_info),
629 630 631 632 633 634 635 636 637 638 639 640 641 642
	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),
643 644 645 646
	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),
647
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
648 649 650 651 652 653 654
	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),
655
	INTEL_VLV_IDS(&intel_valleyview_info),
656 657
	INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
	INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
658
	INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
659
	INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
660
	INTEL_CHV_IDS(&intel_cherryview_info),
661 662
	INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
	INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
663
	INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
664
	INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
665
	INTEL_BXT_IDS(&intel_broxton_info),
666
	INTEL_GLK_IDS(&intel_geminilake_info),
667 668
	INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
	INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
669 670
	INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
	INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
671
	INTEL_AML_GT2_IDS(&intel_kabylake_gt2_info),
672 673 674
	INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
	INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
675
	INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
676
	INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
677 678 679
	INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
	INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
680
	INTEL_CNL_IDS(&intel_cannonlake_info),
P
Paulo Zanoni 已提交
681
	INTEL_ICL_11_IDS(&intel_icelake_11_info),
682 683 684 685
	{0, 0, 0}
};
MODULE_DEVICE_TABLE(pci, pciidlist);

686 687
static void i915_pci_remove(struct pci_dev *pdev)
{
688 689 690 691 692
	struct drm_device *dev;

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

	i915_driver_unload(dev);
695
	drm_dev_put(dev);
696 697

	pci_set_drvdata(pdev, NULL);
698 699
}

700 701 702 703
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;
704
	int err;
705

706
	if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
707 708 709
		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");
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
		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;

728 729 730
	err = i915_driver_load(pdev, ent);
	if (err)
		return err;
731

732 733 734 735 736
	if (i915_inject_load_failure()) {
		i915_pci_remove(pdev);
		return -ENODEV;
	}

737 738 739 740 741
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
742

743
	return 0;
744 745
}

746
static struct pci_driver i915_pci_driver = {
747 748 749 750 751 752
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.driver.pm = &i915_pm_ops,
};
753 754 755 756

static int __init i915_init(void)
{
	bool use_kms = true;
757 758 759 760 761
	int err;

	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
762 763 764 765 766 767 768

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

769
	if (i915_modparams.modeset == 0)
770 771
		use_kms = false;

772
	if (vgacon_text_force() && i915_modparams.modeset == -1)
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
		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);
}

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