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

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

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

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

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

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

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

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

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

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

128
#define GEN3_FEATURES \
129 130
	GEN(3), \
	.num_pipes = 2, \
131
	.display.has_gmch_display = 1, \
132
	.gpu_reset_clobbers_display = true, \
133
	.ring_mask = RENDER_RING, \
134
	.has_snoop = true, \
135
	.has_coherent_ggtt = true, \
136
	GEN_DEFAULT_PIPEOFFSETS, \
137
	GEN_DEFAULT_PAGE_SIZES, \
138 139
	CURSOR_OFFSETS

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

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

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

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

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

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

204
#define GEN4_FEATURES \
205 206
	GEN(4), \
	.num_pipes = 2, \
207 208
	.display.has_hotplug = 1, \
	.display.has_gmch_display = 1, \
209
	.gpu_reset_clobbers_display = true, \
210
	.ring_mask = RENDER_RING, \
211
	.has_snoop = true, \
212
	.has_coherent_ggtt = true, \
213
	GEN_DEFAULT_PIPEOFFSETS, \
214
	GEN_DEFAULT_PAGE_SIZES, \
215 216
	CURSOR_OFFSETS

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

657
#undef GEN
658
#undef PLATFORM
659

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

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

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

	i915_driver_unload(dev);
736
	drm_dev_put(dev);
737 738

	pci_set_drvdata(pdev, NULL);
739 740
}

741 742 743 744
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;
745
	int err;
746

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

769 770 771
	err = i915_driver_load(pdev, ent);
	if (err)
		return err;
772

773 774 775 776 777
	if (i915_inject_load_failure()) {
		i915_pci_remove(pdev);
		return -ENODEV;
	}

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

784
	return 0;
785 786
}

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

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

	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
803 804 805 806 807 808 809

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

810
	if (i915_modparams.modeset == 0)
811 812
		use_kms = false;

813
	if (vgacon_text_force() && i915_modparams.modeset == -1)
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
		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");