i915_pci.c 19.3 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
	GEN_DEFAULT_PIPEOFFSETS, \
78
	GEN_DEFAULT_PAGE_SIZES, \
79 80
	CURSOR_OFFSETS

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

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

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

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

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

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

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

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

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

159
static const struct intel_device_info intel_g33_info = {
160
	GEN3_FEATURES,
161
	PLATFORM(INTEL_G33),
162 163 164 165
	.has_hotplug = 1,
	.has_overlay = 1,
};

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

174
#define GEN4_FEATURES \
175 176
	GEN(4), \
	.num_pipes = 2, \
177
	.has_hotplug = 1, \
178
	.has_gmch_display = 1, \
179
	.ring_mask = RENDER_RING, \
180
	.has_snoop = true, \
181
	GEN_DEFAULT_PIPEOFFSETS, \
182
	GEN_DEFAULT_PAGE_SIZES, \
183 184
	CURSOR_OFFSETS

185
static const struct intel_device_info intel_i965g_info = {
186
	GEN4_FEATURES,
187
	PLATFORM(INTEL_I965G),
188
	.has_overlay = 1,
189
	.hws_needs_physical = 1,
190
	.has_snoop = false,
191 192
};

193
static const struct intel_device_info intel_i965gm_info = {
194
	GEN4_FEATURES,
195
	PLATFORM(INTEL_I965GM),
196
	.is_mobile = 1, .has_fbc = 1,
197 198
	.has_overlay = 1,
	.supports_tv = 1,
199
	.hws_needs_physical = 1,
200
	.has_snoop = false,
201 202
};

203
static const struct intel_device_info intel_g45_info = {
204
	GEN4_FEATURES,
205
	PLATFORM(INTEL_G45),
206 207 208
	.ring_mask = RENDER_RING | BSD_RING,
};

209
static const struct intel_device_info intel_gm45_info = {
210
	GEN4_FEATURES,
211
	PLATFORM(INTEL_GM45),
212
	.is_mobile = 1, .has_fbc = 1,
213 214 215 216
	.supports_tv = 1,
	.ring_mask = RENDER_RING | BSD_RING,
};

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

229
static const struct intel_device_info intel_ironlake_d_info = {
230
	GEN5_FEATURES,
231
	PLATFORM(INTEL_IRONLAKE),
232 233
};

234
static const struct intel_device_info intel_ironlake_m_info = {
235
	GEN5_FEATURES,
236
	PLATFORM(INTEL_IRONLAKE),
237
	.is_mobile = 1, .has_fbc = 1,
238 239
};

240
#define GEN6_FEATURES \
241 242
	GEN(6), \
	.num_pipes = 2, \
243
	.has_hotplug = 1, \
244 245 246
	.has_fbc = 1, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
	.has_llc = 1, \
247
	.has_rc6 = 1, \
248
	.has_rc6p = 1, \
249
	.has_aliasing_ppgtt = 1, \
250
	GEN_DEFAULT_PIPEOFFSETS, \
251
	GEN_DEFAULT_PAGE_SIZES, \
252 253
	CURSOR_OFFSETS

254 255
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
256
	PLATFORM(INTEL_SANDYBRIDGE)
257

258
static const struct intel_device_info intel_sandybridge_d_gt1_info = {
259 260
	SNB_D_PLATFORM,
	.gt = 1,
261 262
};

263
static const struct intel_device_info intel_sandybridge_d_gt2_info = {
264 265 266 267 268 269
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
270
	PLATFORM(INTEL_SANDYBRIDGE), \
271 272 273
	.is_mobile = 1


274
static const struct intel_device_info intel_sandybridge_m_gt1_info = {
275 276 277 278
	SNB_M_PLATFORM,
	.gt = 1,
};

279
static const struct intel_device_info intel_sandybridge_m_gt2_info = {
280 281
	SNB_M_PLATFORM,
	.gt = 2,
282 283 284
};

#define GEN7_FEATURES  \
285 286
	GEN(7), \
	.num_pipes = 3, \
287
	.has_hotplug = 1, \
288 289 290
	.has_fbc = 1, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
	.has_llc = 1, \
291
	.has_rc6 = 1, \
292
	.has_rc6p = 1, \
293 294
	.has_aliasing_ppgtt = 1, \
	.has_full_ppgtt = 1, \
295
	GEN_DEFAULT_PIPEOFFSETS, \
296
	GEN_DEFAULT_PAGE_SIZES, \
297 298
	IVB_CURSOR_OFFSETS

299 300
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
301
	PLATFORM(INTEL_IVYBRIDGE), \
302 303
	.has_l3_dpf = 1

304
static const struct intel_device_info intel_ivybridge_d_gt1_info = {
305 306
	IVB_D_PLATFORM,
	.gt = 1,
307 308
};

309
static const struct intel_device_info intel_ivybridge_d_gt2_info = {
310 311 312 313 314 315
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
316
	PLATFORM(INTEL_IVYBRIDGE), \
317 318 319
	.is_mobile = 1, \
	.has_l3_dpf = 1

320
static const struct intel_device_info intel_ivybridge_m_gt1_info = {
321 322 323 324
	IVB_M_PLATFORM,
	.gt = 1,
};

325
static const struct intel_device_info intel_ivybridge_m_gt2_info = {
326 327
	IVB_M_PLATFORM,
	.gt = 2,
328 329
};

330
static const struct intel_device_info intel_ivybridge_q_info = {
331
	GEN7_FEATURES,
332
	PLATFORM(INTEL_IVYBRIDGE),
333
	.gt = 2,
334
	.num_pipes = 0, /* legal, last one wins */
335
	.has_l3_dpf = 1,
336 337
};

338
static const struct intel_device_info intel_valleyview_info = {
339
	PLATFORM(INTEL_VALLEYVIEW),
340
	GEN(7),
341 342 343 344 345 346 347 348
	.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,
349
	.has_snoop = true,
350 351
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
	.display_mmio_offset = VLV_DISPLAY_BASE,
352
	GEN_DEFAULT_PAGE_SIZES,
353 354
	GEN_DEFAULT_PIPEOFFSETS,
	CURSOR_OFFSETS
355 356
};

357
#define G75_FEATURES  \
358 359 360
	GEN7_FEATURES, \
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
	.has_ddi = 1, \
361
	.has_fpga_dbg = 1, \
362
	.has_psr = 1, \
363
	.has_resource_streamer = 1, \
364
	.has_dp_mst = 1, \
365
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
366
	.has_runtime_pm = 1
367

368
#define HSW_PLATFORM \
369
	G75_FEATURES, \
370
	PLATFORM(INTEL_HASWELL), \
371 372
	.has_l3_dpf = 1

373
static const struct intel_device_info intel_haswell_gt1_info = {
374 375 376 377
	HSW_PLATFORM,
	.gt = 1,
};

378
static const struct intel_device_info intel_haswell_gt2_info = {
379 380 381 382
	HSW_PLATFORM,
	.gt = 2,
};

383
static const struct intel_device_info intel_haswell_gt3_info = {
384 385
	HSW_PLATFORM,
	.gt = 3,
386 387
};

388 389
#define GEN8_FEATURES \
	G75_FEATURES, \
390
	GEN(8), \
391
	BDW_COLORS, \
392 393
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_2M, \
394
	.has_logical_ring_contexts = 1, \
395
	.has_full_48bit_ppgtt = 1, \
396 397
	.has_64bit_reloc = 1, \
	.has_reset_engine = 1
398

399
#define BDW_PLATFORM \
400
	GEN8_FEATURES, \
401
	PLATFORM(INTEL_BROADWELL)
402

403
static const struct intel_device_info intel_broadwell_gt1_info = {
404 405 406 407
	BDW_PLATFORM,
	.gt = 1,
};

408
static const struct intel_device_info intel_broadwell_gt2_info = {
409
	BDW_PLATFORM,
410 411 412
	.gt = 2,
};

413
static const struct intel_device_info intel_broadwell_rsvd_info = {
414 415 416 417 418
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
419 420
};

421
static const struct intel_device_info intel_broadwell_gt3_info = {
422
	BDW_PLATFORM,
423
	.gt = 3,
424 425 426
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

427
static const struct intel_device_info intel_cherryview_info = {
428
	PLATFORM(INTEL_CHERRYVIEW),
429 430
	GEN(8),
	.num_pipes = 3,
431
	.has_hotplug = 1,
432
	.is_lp = 1,
433
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
434
	.has_64bit_reloc = 1,
435
	.has_runtime_pm = 1,
436
	.has_resource_streamer = 1,
437
	.has_rc6 = 1,
438
	.has_logical_ring_contexts = 1,
439
	.has_gmch_display = 1,
440 441
	.has_aliasing_ppgtt = 1,
	.has_full_ppgtt = 1,
442
	.has_reset_engine = 1,
443
	.has_snoop = true,
444
	.display_mmio_offset = VLV_DISPLAY_BASE,
445
	GEN_DEFAULT_PAGE_SIZES,
446 447 448 449 450
	GEN_CHV_PIPEOFFSETS,
	CURSOR_OFFSETS,
	CHV_COLORS,
};

451
#define GEN9_DEFAULT_PAGE_SIZES \
452
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
453 454
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M
455

456 457
#define GEN9_FEATURES \
	GEN8_FEATURES, \
458
	GEN(9), \
459
	GEN9_DEFAULT_PAGE_SIZES, \
C
Chris Wilson 已提交
460
	.has_logical_ring_preemption = 1, \
461 462
	.has_csr = 1, \
	.has_guc = 1, \
463
	.has_ipc = 1, \
464 465
	.ddb_size = 896

466 467
#define SKL_PLATFORM \
	GEN9_FEATURES, \
468
	PLATFORM(INTEL_SKYLAKE)
469

470
static const struct intel_device_info intel_skylake_gt1_info = {
471
	SKL_PLATFORM,
472
	.gt = 1,
473 474
};

475
static const struct intel_device_info intel_skylake_gt2_info = {
476
	SKL_PLATFORM,
477 478 479 480 481 482 483 484
	.gt = 2,
};

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


485
static const struct intel_device_info intel_skylake_gt3_info = {
486 487 488 489
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

490
static const struct intel_device_info intel_skylake_gt4_info = {
491 492
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
493 494
};

495
#define GEN9_LP_FEATURES \
496
	GEN(9), \
497
	.is_lp = 1, \
498 499 500 501 502 503 504
	.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, \
505
	.has_psr = 1, \
506 507 508 509 510 511 512
	.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 已提交
513
	.has_logical_ring_preemption = 1, \
514
	.has_guc = 1, \
515 516 517
	.has_aliasing_ppgtt = 1, \
	.has_full_ppgtt = 1, \
	.has_full_48bit_ppgtt = 1, \
518
	.has_reset_engine = 1, \
519
	.has_snoop = true, \
520
	.has_ipc = 1, \
521
	GEN9_DEFAULT_PAGE_SIZES, \
522 523 524 525
	GEN_DEFAULT_PIPEOFFSETS, \
	IVB_CURSOR_OFFSETS, \
	BDW_COLORS

526
static const struct intel_device_info intel_broxton_info = {
527
	GEN9_LP_FEATURES,
528
	PLATFORM(INTEL_BROXTON),
529
	.ddb_size = 512,
530 531
};

532
static const struct intel_device_info intel_geminilake_info = {
533
	GEN9_LP_FEATURES,
534
	PLATFORM(INTEL_GEMINILAKE),
535
	.ddb_size = 1024,
R
Rodrigo Vivi 已提交
536
	GLK_COLORS,
537 538
};

539
#define KBL_PLATFORM \
540
	GEN9_FEATURES, \
541
	PLATFORM(INTEL_KABYLAKE)
542

543
static const struct intel_device_info intel_kabylake_gt1_info = {
544
	KBL_PLATFORM,
545 546 547
	.gt = 1,
};

548
static const struct intel_device_info intel_kabylake_gt2_info = {
549 550
	KBL_PLATFORM,
	.gt = 2,
551 552
};

553
static const struct intel_device_info intel_kabylake_gt3_info = {
554
	KBL_PLATFORM,
555
	.gt = 3,
556 557 558
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

559
#define CFL_PLATFORM \
560
	GEN9_FEATURES, \
561
	PLATFORM(INTEL_COFFEELAKE)
562

563
static const struct intel_device_info intel_coffeelake_gt1_info = {
564 565 566 567
	CFL_PLATFORM,
	.gt = 1,
};

568
static const struct intel_device_info intel_coffeelake_gt2_info = {
569
	CFL_PLATFORM,
570
	.gt = 2,
571 572
};

573
static const struct intel_device_info intel_coffeelake_gt3_info = {
574
	CFL_PLATFORM,
575
	.gt = 3,
576 577 578
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
};

579 580
#define GEN10_FEATURES \
	GEN9_FEATURES, \
581
	GEN(10), \
582
	.ddb_size = 1024, \
R
Rodrigo Vivi 已提交
583
	GLK_COLORS
584

585
static const struct intel_device_info intel_cannonlake_info = {
586
	GEN10_FEATURES,
587
	PLATFORM(INTEL_CANNONLAKE),
588
	.gt = 2,
589 590
};

591 592
#define GEN11_FEATURES \
	GEN10_FEATURES, \
593
	GEN(11), \
594
	.ddb_size = 2048, \
595 596
	.has_csr = 0, \
	.has_logical_ring_elsq = 1
597

598
static const struct intel_device_info intel_icelake_11_info = {
599
	GEN11_FEATURES,
600
	PLATFORM(INTEL_ICELAKE),
601 602
	.is_alpha_support = 1,
	.has_resource_streamer = 0,
603
	.ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING,
604 605
};

606
#undef GEN
607
#undef PLATFORM
608

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

674 675 676 677 678
static void i915_pci_remove(struct pci_dev *pdev)
{
	struct drm_device *dev = pci_get_drvdata(pdev);

	i915_driver_unload(dev);
679
	drm_dev_put(dev);
680 681
}

682 683 684 685
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;
686
	int err;
687

688
	if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
689 690 691
		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");
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
		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;

710 711 712
	err = i915_driver_load(pdev, ent);
	if (err)
		return err;
713

714 715 716 717 718
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
719

720
	return 0;
721 722
}

723
static struct pci_driver i915_pci_driver = {
724 725 726 727 728 729
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.driver.pm = &i915_pm_ops,
};
730 731 732 733

static int __init i915_init(void)
{
	bool use_kms = true;
734 735 736 737 738
	int err;

	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
739 740 741 742 743 744 745

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

746
	if (i915_modparams.modeset == 0)
747 748
		use_kms = false;

749
	if (vgacon_text_force() && i915_modparams.modeset == -1)
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
		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");