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

28 29
#include <drm/drm_drv.h>

30 31
#include "display/intel_fbdev.h"

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

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

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

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

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

#define HSW_PIPE_OFFSETS \
70 71 72 73 74 75 76 77 78 79 80 81
	.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, \
	}
82

83
#define CHV_PIPE_OFFSETS \
84 85 86 87 88 89 90 91 92 93
	.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, \
	}
94

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

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

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

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

120 121 122 123 124 125 126 127
#define TGL_CURSOR_OFFSETS \
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
		[PIPE_B] = IVB_CURSOR_B_OFFSET, \
		[PIPE_C] = IVB_CURSOR_C_OFFSET, \
		[PIPE_D] = TGL_CURSOR_D_OFFSET, \
	}

128 129
#define I9XX_COLORS \
	.color = { .gamma_lut_size = 256 }
130 131 132 133
#define I965_COLORS \
	.color = { .gamma_lut_size = 129, \
		   .gamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING, \
	}
134 135
#define ILK_COLORS \
	.color = { .gamma_lut_size = 1024 }
136
#define IVB_COLORS \
137
	.color = { .degamma_lut_size = 1024, .gamma_lut_size = 1024 }
138
#define CHV_COLORS \
139 140 141 142
	.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 已提交
143
#define GLK_COLORS \
144
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 1024, \
145 146 147
		   .degamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING | \
					DRM_COLOR_LUT_EQUAL_CHANNELS, \
	}
148

149
/* Keep in gen based order, and chronological order within a gen */
150 151 152 153

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

M
Matthew Auld 已提交
154 155 156
#define GEN_DEFAULT_REGIONS \
	.memory_regions = REGION_SMEM

157 158 159
#define I830_FEATURES \
	GEN(2), \
	.is_mobile = 1, \
160
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
161 162 163 164 165 166 167 168 169 170 171 172
	.display.has_overlay = 1, \
	.display.cursor_needs_physical = 1, \
	.display.overlay_needs_physical = 1, \
	.display.has_gmch = 1, \
	.gpu_reset_clobbers_display = true, \
	.hws_needs_physical = 1, \
	.unfenced_needs_alignment = 1, \
	.engine_mask = BIT(RCS0), \
	.has_snoop = true, \
	.has_coherent_ggtt = false, \
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
173
	I9XX_COLORS, \
M
Matthew Auld 已提交
174 175
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
176 177

#define I845_FEATURES \
178
	GEN(2), \
179
	.pipe_mask = BIT(PIPE_A), \
180 181
	.display.has_overlay = 1, \
	.display.overlay_needs_physical = 1, \
R
Rodrigo Vivi 已提交
182
	.display.has_gmch = 1, \
183
	.gpu_reset_clobbers_display = true, \
184
	.hws_needs_physical = 1, \
185
	.unfenced_needs_alignment = 1, \
186
	.engine_mask = BIT(RCS0), \
187
	.has_snoop = true, \
188
	.has_coherent_ggtt = false, \
189 190
	I845_PIPE_OFFSETS, \
	I845_CURSOR_OFFSETS, \
191
	I9XX_COLORS, \
M
Matthew Auld 已提交
192 193
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
194

195
static const struct intel_device_info intel_i830_info = {
196
	I830_FEATURES,
197
	PLATFORM(INTEL_I830),
198 199
};

200
static const struct intel_device_info intel_i845g_info = {
201
	I845_FEATURES,
202
	PLATFORM(INTEL_I845G),
203 204
};

205
static const struct intel_device_info intel_i85x_info = {
206
	I830_FEATURES,
207
	PLATFORM(INTEL_I85X),
208
	.display.has_fbc = 1,
209 210
};

211
static const struct intel_device_info intel_i865g_info = {
212
	I845_FEATURES,
213
	PLATFORM(INTEL_I865G),
214 215
};

216
#define GEN3_FEATURES \
217
	GEN(3), \
218
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
R
Rodrigo Vivi 已提交
219
	.display.has_gmch = 1, \
220
	.gpu_reset_clobbers_display = true, \
221
	.engine_mask = BIT(RCS0), \
222
	.has_snoop = true, \
223
	.has_coherent_ggtt = true, \
224 225
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
226
	I9XX_COLORS, \
M
Matthew Auld 已提交
227 228
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
229

230
static const struct intel_device_info intel_i915g_info = {
231
	GEN3_FEATURES,
232
	PLATFORM(INTEL_I915G),
233
	.has_coherent_ggtt = false,
234 235 236
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
237
	.hws_needs_physical = 1,
238
	.unfenced_needs_alignment = 1,
239
};
240

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

254
static const struct intel_device_info intel_i945g_info = {
255
	GEN3_FEATURES,
256
	PLATFORM(INTEL_I945G),
257 258 259 260
	.display.has_hotplug = 1,
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
261
	.hws_needs_physical = 1,
262
	.unfenced_needs_alignment = 1,
263
};
264

265
static const struct intel_device_info intel_i945gm_info = {
266
	GEN3_FEATURES,
267 268
	PLATFORM(INTEL_I945GM),
	.is_mobile = 1,
269 270 271 272 273 274
	.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,
275
	.hws_needs_physical = 1,
276
	.unfenced_needs_alignment = 1,
277 278
};

279
static const struct intel_device_info intel_g33_info = {
280
	GEN3_FEATURES,
281
	PLATFORM(INTEL_G33),
282 283
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
284 285
};

286 287 288 289 290 291 292 293
static const struct intel_device_info intel_pineview_g_info = {
	GEN3_FEATURES,
	PLATFORM(INTEL_PINEVIEW),
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
};

static const struct intel_device_info intel_pineview_m_info = {
294
	GEN3_FEATURES,
295 296
	PLATFORM(INTEL_PINEVIEW),
	.is_mobile = 1,
297 298
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
299 300
};

301
#define GEN4_FEATURES \
302
	GEN(4), \
303
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
304
	.display.has_hotplug = 1, \
R
Rodrigo Vivi 已提交
305
	.display.has_gmch = 1, \
306
	.gpu_reset_clobbers_display = true, \
307
	.engine_mask = BIT(RCS0), \
308
	.has_snoop = true, \
309
	.has_coherent_ggtt = true, \
310 311
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
312
	I965_COLORS, \
M
Matthew Auld 已提交
313 314
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
315

316
static const struct intel_device_info intel_i965g_info = {
317
	GEN4_FEATURES,
318
	PLATFORM(INTEL_I965G),
319
	.display.has_overlay = 1,
320
	.hws_needs_physical = 1,
321
	.has_snoop = false,
322 323
};

324
static const struct intel_device_info intel_i965gm_info = {
325
	GEN4_FEATURES,
326
	PLATFORM(INTEL_I965GM),
327 328 329 330
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.has_overlay = 1,
	.display.supports_tv = 1,
331
	.hws_needs_physical = 1,
332
	.has_snoop = false,
333 334
};

335
static const struct intel_device_info intel_g45_info = {
336
	GEN4_FEATURES,
337
	PLATFORM(INTEL_G45),
338
	.engine_mask = BIT(RCS0) | BIT(VCS0),
339
	.gpu_reset_clobbers_display = false,
340 341
};

342
static const struct intel_device_info intel_gm45_info = {
343
	GEN4_FEATURES,
344
	PLATFORM(INTEL_GM45),
345 346 347
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.supports_tv = 1,
348
	.engine_mask = BIT(RCS0) | BIT(VCS0),
349
	.gpu_reset_clobbers_display = false,
350 351
};

352
#define GEN5_FEATURES \
353
	GEN(5), \
354
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
355
	.display.has_hotplug = 1, \
356
	.engine_mask = BIT(RCS0) | BIT(VCS0), \
357
	.has_snoop = true, \
358
	.has_coherent_ggtt = true, \
359 360
	/* ilk does support rc6, but we do not implement [power] contexts */ \
	.has_rc6 = 0, \
361 362
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
363
	ILK_COLORS, \
M
Matthew Auld 已提交
364 365
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
366

367
static const struct intel_device_info intel_ironlake_d_info = {
368
	GEN5_FEATURES,
369
	PLATFORM(INTEL_IRONLAKE),
370 371
};

372
static const struct intel_device_info intel_ironlake_m_info = {
373
	GEN5_FEATURES,
374
	PLATFORM(INTEL_IRONLAKE),
375 376
	.is_mobile = 1,
	.display.has_fbc = 1,
377 378
};

379
#define GEN6_FEATURES \
380
	GEN(6), \
381
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
382 383
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
384
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
385
	.has_coherent_ggtt = true, \
386
	.has_llc = 1, \
387
	.has_rc6 = 1, \
388
	.has_rc6p = 1, \
389
	.has_rps = true, \
390 391
	.ppgtt_type = INTEL_PPGTT_ALIASING, \
	.ppgtt_size = 31, \
392 393
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
394
	ILK_COLORS, \
M
Matthew Auld 已提交
395 396
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
397

398 399
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
400
	PLATFORM(INTEL_SANDYBRIDGE)
401

402
static const struct intel_device_info intel_sandybridge_d_gt1_info = {
403 404
	SNB_D_PLATFORM,
	.gt = 1,
405 406
};

407
static const struct intel_device_info intel_sandybridge_d_gt2_info = {
408 409 410 411 412 413
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
414
	PLATFORM(INTEL_SANDYBRIDGE), \
415 416 417
	.is_mobile = 1


418
static const struct intel_device_info intel_sandybridge_m_gt1_info = {
419 420 421 422
	SNB_M_PLATFORM,
	.gt = 1,
};

423
static const struct intel_device_info intel_sandybridge_m_gt2_info = {
424 425
	SNB_M_PLATFORM,
	.gt = 2,
426 427 428
};

#define GEN7_FEATURES  \
429
	GEN(7), \
430
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), \
431 432
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
433
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
434
	.has_coherent_ggtt = true, \
435
	.has_llc = 1, \
436
	.has_rc6 = 1, \
437
	.has_rc6p = 1, \
438
	.has_rps = true, \
439
	.ppgtt_type = INTEL_PPGTT_ALIASING, \
440
	.ppgtt_size = 31, \
441 442
	IVB_PIPE_OFFSETS, \
	IVB_CURSOR_OFFSETS, \
443
	IVB_COLORS, \
M
Matthew Auld 已提交
444 445
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
446

447 448
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
449
	PLATFORM(INTEL_IVYBRIDGE), \
450 451
	.has_l3_dpf = 1

452
static const struct intel_device_info intel_ivybridge_d_gt1_info = {
453 454
	IVB_D_PLATFORM,
	.gt = 1,
455 456
};

457
static const struct intel_device_info intel_ivybridge_d_gt2_info = {
458 459 460 461 462 463
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
464
	PLATFORM(INTEL_IVYBRIDGE), \
465 466 467
	.is_mobile = 1, \
	.has_l3_dpf = 1

468
static const struct intel_device_info intel_ivybridge_m_gt1_info = {
469 470 471 472
	IVB_M_PLATFORM,
	.gt = 1,
};

473
static const struct intel_device_info intel_ivybridge_m_gt2_info = {
474 475
	IVB_M_PLATFORM,
	.gt = 2,
476 477
};

478
static const struct intel_device_info intel_ivybridge_q_info = {
479
	GEN7_FEATURES,
480
	PLATFORM(INTEL_IVYBRIDGE),
481
	.gt = 2,
482
	.pipe_mask = 0, /* legal, last one wins */
483
	.has_l3_dpf = 1,
484 485
};

486
static const struct intel_device_info intel_valleyview_info = {
487
	PLATFORM(INTEL_VALLEYVIEW),
488
	GEN(7),
489
	.is_lp = 1,
490
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B),
491 492
	.has_runtime_pm = 1,
	.has_rc6 = 1,
493
	.has_rps = true,
R
Rodrigo Vivi 已提交
494
	.display.has_gmch = 1,
495
	.display.has_hotplug = 1,
496
	.ppgtt_type = INTEL_PPGTT_ALIASING,
497
	.ppgtt_size = 31,
498
	.has_snoop = true,
499
	.has_coherent_ggtt = false,
500
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0),
501
	.display_mmio_offset = VLV_DISPLAY_BASE,
502 503
	I9XX_PIPE_OFFSETS,
	I9XX_CURSOR_OFFSETS,
504
	I965_COLORS,
505
	GEN_DEFAULT_PAGE_SIZES,
M
Matthew Auld 已提交
506
	GEN_DEFAULT_REGIONS,
507 508
};

509
#define G75_FEATURES  \
510
	GEN7_FEATURES, \
511
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
512
	.display.has_ddi = 1, \
513
	.has_fpga_dbg = 1, \
514 515
	.display.has_psr = 1, \
	.display.has_dp_mst = 1, \
516
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
517
	HSW_PIPE_OFFSETS, \
518
	.has_runtime_pm = 1
519

520
#define HSW_PLATFORM \
521
	G75_FEATURES, \
522
	PLATFORM(INTEL_HASWELL), \
523 524
	.has_l3_dpf = 1

525
static const struct intel_device_info intel_haswell_gt1_info = {
526 527 528 529
	HSW_PLATFORM,
	.gt = 1,
};

530
static const struct intel_device_info intel_haswell_gt2_info = {
531 532 533 534
	HSW_PLATFORM,
	.gt = 2,
};

535
static const struct intel_device_info intel_haswell_gt3_info = {
536 537
	HSW_PLATFORM,
	.gt = 3,
538 539
};

540 541
#define GEN8_FEATURES \
	G75_FEATURES, \
542
	GEN(8), \
543
	.has_logical_ring_contexts = 1, \
544
	.ppgtt_type = INTEL_PPGTT_FULL, \
545
	.ppgtt_size = 48, \
546 547
	.has_64bit_reloc = 1, \
	.has_reset_engine = 1
548

549
#define BDW_PLATFORM \
550
	GEN8_FEATURES, \
551
	PLATFORM(INTEL_BROADWELL)
552

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

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

563
static const struct intel_device_info intel_broadwell_rsvd_info = {
564 565 566 567 568
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
569 570
};

571
static const struct intel_device_info intel_broadwell_gt3_info = {
572
	BDW_PLATFORM,
573
	.gt = 3,
574 575
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
576 577
};

578
static const struct intel_device_info intel_cherryview_info = {
579
	PLATFORM(INTEL_CHERRYVIEW),
580
	GEN(8),
581
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C),
582
	.display.has_hotplug = 1,
583
	.is_lp = 1,
584
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0),
585
	.has_64bit_reloc = 1,
586
	.has_runtime_pm = 1,
587
	.has_rc6 = 1,
588
	.has_rps = true,
589
	.has_logical_ring_contexts = 1,
R
Rodrigo Vivi 已提交
590
	.display.has_gmch = 1,
591
	.ppgtt_type = INTEL_PPGTT_ALIASING,
592
	.ppgtt_size = 32,
593
	.has_reset_engine = 1,
594
	.has_snoop = true,
595
	.has_coherent_ggtt = false,
596
	.display_mmio_offset = VLV_DISPLAY_BASE,
597 598
	CHV_PIPE_OFFSETS,
	CHV_CURSOR_OFFSETS,
599
	CHV_COLORS,
600
	GEN_DEFAULT_PAGE_SIZES,
M
Matthew Auld 已提交
601
	GEN_DEFAULT_REGIONS,
602 603
};

604
#define GEN9_DEFAULT_PAGE_SIZES \
605
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
606
		      I915_GTT_PAGE_SIZE_64K
607

608 609
#define GEN9_FEATURES \
	GEN8_FEATURES, \
610
	GEN(9), \
611
	GEN9_DEFAULT_PAGE_SIZES, \
C
Chris Wilson 已提交
612
	.has_logical_ring_preemption = 1, \
613
	.display.has_csr = 1, \
614
	.has_gt_uc = 1, \
615
	.display.has_ipc = 1, \
616 617
	.ddb_size = 896

618 619
#define SKL_PLATFORM \
	GEN9_FEATURES, \
620
	PLATFORM(INTEL_SKYLAKE)
621

622
static const struct intel_device_info intel_skylake_gt1_info = {
623
	SKL_PLATFORM,
624
	.gt = 1,
625 626
};

627
static const struct intel_device_info intel_skylake_gt2_info = {
628
	SKL_PLATFORM,
629 630 631 632 633
	.gt = 2,
};

#define SKL_GT3_PLUS_PLATFORM \
	SKL_PLATFORM, \
634 635
	.engine_mask = \
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1)
636 637


638
static const struct intel_device_info intel_skylake_gt3_info = {
639 640 641 642
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

643
static const struct intel_device_info intel_skylake_gt4_info = {
644 645
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
646 647
};

648
#define GEN9_LP_FEATURES \
649
	GEN(9), \
650
	.is_lp = 1, \
651
	.display.has_hotplug = 1, \
652
	.engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
653
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), \
654
	.has_64bit_reloc = 1, \
655
	.display.has_ddi = 1, \
656
	.has_fpga_dbg = 1, \
657 658
	.display.has_fbc = 1, \
	.display.has_psr = 1, \
659
	.has_runtime_pm = 1, \
660
	.display.has_csr = 1, \
661
	.has_rc6 = 1, \
662
	.has_rps = true, \
663
	.display.has_dp_mst = 1, \
664
	.has_logical_ring_contexts = 1, \
C
Chris Wilson 已提交
665
	.has_logical_ring_preemption = 1, \
666
	.has_gt_uc = 1, \
667
	.ppgtt_type = INTEL_PPGTT_FULL, \
668
	.ppgtt_size = 48, \
669
	.has_reset_engine = 1, \
670
	.has_snoop = true, \
671
	.has_coherent_ggtt = false, \
672
	.display.has_ipc = 1, \
673
	HSW_PIPE_OFFSETS, \
674
	IVB_CURSOR_OFFSETS, \
675
	IVB_COLORS, \
M
Matthew Auld 已提交
676 677
	GEN9_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
678

679
static const struct intel_device_info intel_broxton_info = {
680
	GEN9_LP_FEATURES,
681
	PLATFORM(INTEL_BROXTON),
682
	.ddb_size = 512,
683 684
};

685
static const struct intel_device_info intel_geminilake_info = {
686
	GEN9_LP_FEATURES,
687
	PLATFORM(INTEL_GEMINILAKE),
688
	.ddb_size = 1024,
R
Rodrigo Vivi 已提交
689
	GLK_COLORS,
690 691
};

692
#define KBL_PLATFORM \
693
	GEN9_FEATURES, \
694
	PLATFORM(INTEL_KABYLAKE)
695

696
static const struct intel_device_info intel_kabylake_gt1_info = {
697
	KBL_PLATFORM,
698 699 700
	.gt = 1,
};

701
static const struct intel_device_info intel_kabylake_gt2_info = {
702 703
	KBL_PLATFORM,
	.gt = 2,
704 705
};

706
static const struct intel_device_info intel_kabylake_gt3_info = {
707
	KBL_PLATFORM,
708
	.gt = 3,
709 710
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
711 712
};

713
#define CFL_PLATFORM \
714
	GEN9_FEATURES, \
715
	PLATFORM(INTEL_COFFEELAKE)
716

717
static const struct intel_device_info intel_coffeelake_gt1_info = {
718 719 720 721
	CFL_PLATFORM,
	.gt = 1,
};

722
static const struct intel_device_info intel_coffeelake_gt2_info = {
723
	CFL_PLATFORM,
724
	.gt = 2,
725 726
};

727
static const struct intel_device_info intel_coffeelake_gt3_info = {
728
	CFL_PLATFORM,
729
	.gt = 3,
730 731
	.engine_mask =
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
732 733
};

734 735
#define GEN10_FEATURES \
	GEN9_FEATURES, \
736
	GEN(10), \
737
	.ddb_size = 1024, \
738
	.has_coherent_ggtt = false, \
R
Rodrigo Vivi 已提交
739
	GLK_COLORS
740

741
static const struct intel_device_info intel_cannonlake_info = {
742
	GEN10_FEATURES,
743
	PLATFORM(INTEL_CANNONLAKE),
744
	.gt = 2,
745 746
};

747 748 749 750 751
#define GEN11_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M

752 753
#define GEN11_FEATURES \
	GEN10_FEATURES, \
754
	GEN11_DEFAULT_PAGE_SIZES, \
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
	.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, \
	}, \
771
	GEN(11), \
772
	.ddb_size = 2048, \
773
	.has_logical_ring_elsq = 1, \
774
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 262145 }
775

776
static const struct intel_device_info intel_icelake_11_info = {
777
	GEN11_FEATURES,
778
	PLATFORM(INTEL_ICELAKE),
779 780
	.engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
781 782
};

783 784
static const struct intel_device_info intel_elkhartlake_info = {
	GEN11_FEATURES,
785
	PLATFORM(INTEL_ELKHARTLAKE),
786
	.require_force_probe = 1,
787
	.engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
788 789 790
	.ppgtt_size = 36,
};

791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
#define GEN12_FEATURES \
	GEN11_FEATURES, \
	GEN(12), \
	.pipe_offsets = { \
		[TRANSCODER_A] = PIPE_A_OFFSET, \
		[TRANSCODER_B] = PIPE_B_OFFSET, \
		[TRANSCODER_C] = PIPE_C_OFFSET, \
		[TRANSCODER_D] = PIPE_D_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_D] = TRANSCODER_D_OFFSET, \
		[TRANSCODER_DSI_0] = TRANSCODER_DSI0_OFFSET, \
		[TRANSCODER_DSI_1] = TRANSCODER_DSI1_OFFSET, \
809
	}, \
810
	TGL_CURSOR_OFFSETS, \
811 812
	.has_global_mocs = 1, \
	.display.has_dsb = 1
813 814 815 816

static const struct intel_device_info intel_tigerlake_12_info = {
	GEN12_FEATURES,
	PLATFORM(INTEL_TIGERLAKE),
817
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D),
818
	.require_force_probe = 1,
819
	.display.has_modular_fia = 1,
820 821
	.engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
822
	.has_rps = false, /* XXX disabled for debugging */
823 824
};

825
#undef GEN
826
#undef PLATFORM
827

828 829 830 831 832 833 834 835
/*
 * 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),
836
	INTEL_I845G_IDS(&intel_i845g_info),
837 838 839 840 841 842 843 844 845 846 847
	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),
848 849
	INTEL_PINEVIEW_G_IDS(&intel_pineview_g_info),
	INTEL_PINEVIEW_M_IDS(&intel_pineview_m_info),
850 851
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
852 853 854 855
	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),
856
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
857 858 859 860 861 862 863
	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),
864
	INTEL_VLV_IDS(&intel_valleyview_info),
865 866
	INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
	INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
867
	INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
868
	INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
869
	INTEL_CHV_IDS(&intel_cherryview_info),
870 871
	INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
	INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
872
	INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
873
	INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
874
	INTEL_BXT_IDS(&intel_broxton_info),
875
	INTEL_GLK_IDS(&intel_geminilake_info),
876 877
	INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
	INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
878 879
	INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
	INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
880
	INTEL_AML_KBL_GT2_IDS(&intel_kabylake_gt2_info),
881 882
	INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
883
	INTEL_CFL_H_GT1_IDS(&intel_coffeelake_gt1_info),
884
	INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
885
	INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
886
	INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
887 888
	INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
889
	INTEL_AML_CFL_GT2_IDS(&intel_coffeelake_gt2_info),
890
	INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
A
Anusha Srivatsa 已提交
891 892
	INTEL_CML_GT1_IDS(&intel_coffeelake_gt1_info),
	INTEL_CML_GT2_IDS(&intel_coffeelake_gt2_info),
893
	INTEL_CNL_IDS(&intel_cannonlake_info),
P
Paulo Zanoni 已提交
894
	INTEL_ICL_11_IDS(&intel_icelake_11_info),
895
	INTEL_EHL_IDS(&intel_elkhartlake_info),
L
Lucas De Marchi 已提交
896
	INTEL_TGL_12_IDS(&intel_tigerlake_12_info),
897 898 899 900
	{0, 0, 0}
};
MODULE_DEVICE_TABLE(pci, pciidlist);

901 902
static void i915_pci_remove(struct pci_dev *pdev)
{
903
	struct drm_i915_private *i915;
904

905 906
	i915 = pci_get_drvdata(pdev);
	if (!i915) /* driver load aborted, nothing to cleanup */
907
		return;
908

909
	i915_driver_remove(i915);
910
	pci_set_drvdata(pdev, NULL);
911 912

	drm_dev_put(&i915->drm);
913 914
}

915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
/* is device_id present in comma separated list of ids */
static bool force_probe(u16 device_id, const char *devices)
{
	char *s, *p, *tok;
	bool ret;

	/* FIXME: transitional */
	if (i915_modparams.alpha_support) {
		DRM_INFO("i915.alpha_support is deprecated, use i915.force_probe=%04x instead\n",
			 device_id);
		return true;
	}

	if (!devices || !*devices)
		return false;

	/* match everything */
	if (strcmp(devices, "*") == 0)
		return true;

	s = kstrdup(devices, GFP_KERNEL);
	if (!s)
		return false;

	for (p = s, ret = false; (tok = strsep(&p, ",")) != NULL; ) {
		u16 val;

		if (kstrtou16(tok, 16, &val) == 0 && val == device_id) {
			ret = true;
			break;
		}
	}

	kfree(s);

	return ret;
}

953 954 955 956
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;
957
	int err;
958

959 960 961 962 963 964 965
	if (intel_info->require_force_probe &&
	    !force_probe(pdev->device, i915_modparams.force_probe)) {
		DRM_INFO("Your graphics device %04x is not properly supported by the driver in this\n"
			 "kernel version. To force driver probe anyway, use i915.force_probe=%04x\n"
			 "module parameter or CONFIG_DRM_I915_FORCE_PROBE=%04x configuration option,\n"
			 "or (recommended) check for kernel updates.\n",
			 pdev->device, pdev->device, pdev->device);
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983
		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;

984
	err = i915_driver_probe(pdev, ent);
985 986
	if (err)
		return err;
987

988
	if (i915_inject_probe_failure(pci_get_drvdata(pdev))) {
989 990 991 992
		i915_pci_remove(pdev);
		return -ENODEV;
	}

993 994 995 996 997
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
998

999
	return 0;
1000 1001
}

1002
static struct pci_driver i915_pci_driver = {
1003 1004 1005 1006 1007 1008
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.driver.pm = &i915_pm_ops,
};
1009 1010 1011 1012

static int __init i915_init(void)
{
	bool use_kms = true;
1013 1014
	int err;

1015 1016 1017
	err = i915_globals_init();
	if (err)
		return err;
1018

1019 1020 1021
	err = i915_mock_selftests();
	if (err)
		return err > 0 ? 0 : err;
1022 1023 1024 1025 1026 1027 1028

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

1029
	if (i915_modparams.modeset == 0)
1030 1031
		use_kms = false;

1032
	if (vgacon_text_force() && i915_modparams.modeset == -1)
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
		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);
1050
	i915_globals_exit();
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
}

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