i915_pci.c 33.1 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
#include <drm/drm_drv.h>
29
#include <drm/i915_pciids.h>
30

31 32
#include "display/intel_fbdev.h"

33
#include "i915_active.h"
34
#include "i915_buddy.h"
35
#include "i915_drv.h"
36
#include "gem/i915_gem_context.h"
37
#include "gem/i915_gem_object.h"
38
#include "i915_perf.h"
39
#include "i915_globals.h"
40
#include "i915_selftest.h"
41

42
#define PLATFORM(x) .platform = (x)
43 44 45 46
#define GEN(x) \
	.graphics_ver = (x), \
	.media_ver = (x), \
	.display.ver = (x)
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#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 \
79 80 81 82 83 84 85 86 87 88 89 90
	.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, \
	}
91

92
#define CHV_PIPE_OFFSETS \
93 94 95 96 97 98 99 100 101 102
	.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, \
	}
103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#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, \
	}
121 122

#define IVB_CURSOR_OFFSETS \
123 124 125 126 127
	.cursor_offsets = { \
		[PIPE_A] = CURSOR_A_OFFSET, \
		[PIPE_B] = IVB_CURSOR_B_OFFSET, \
		[PIPE_C] = IVB_CURSOR_C_OFFSET, \
	}
128

129 130 131 132 133 134 135 136
#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, \
	}

137 138
#define I9XX_COLORS \
	.color = { .gamma_lut_size = 256 }
139 140 141 142
#define I965_COLORS \
	.color = { .gamma_lut_size = 129, \
		   .gamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING, \
	}
143 144
#define ILK_COLORS \
	.color = { .gamma_lut_size = 1024 }
145
#define IVB_COLORS \
146
	.color = { .degamma_lut_size = 1024, .gamma_lut_size = 1024 }
147
#define CHV_COLORS \
148 149 150 151
	.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 已提交
152
#define GLK_COLORS \
153
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 1024, \
154 155 156
		   .degamma_lut_tests = DRM_COLOR_LUT_NON_DECREASING | \
					DRM_COLOR_LUT_EQUAL_CHANNELS, \
	}
157

158
/* Keep in gen based order, and chronological order within a gen */
159 160 161 162

#define GEN_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K

M
Matthew Auld 已提交
163
#define GEN_DEFAULT_REGIONS \
164
	.memory_regions = REGION_SMEM | REGION_STOLEN_SMEM
M
Matthew Auld 已提交
165

166 167 168
#define I830_FEATURES \
	GEN(2), \
	.is_mobile = 1, \
169
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
170
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B), \
171 172 173 174 175 176 177
	.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, \
178
	.platform_engine_mask = BIT(RCS0), \
179 180
	.has_snoop = true, \
	.has_coherent_ggtt = false, \
181
	.dma_mask_size = 32, \
182 183
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
184
	I9XX_COLORS, \
M
Matthew Auld 已提交
185 186
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
187 188

#define I845_FEATURES \
189
	GEN(2), \
190
	.pipe_mask = BIT(PIPE_A), \
191
	.cpu_transcoder_mask = BIT(TRANSCODER_A), \
192 193
	.display.has_overlay = 1, \
	.display.overlay_needs_physical = 1, \
R
Rodrigo Vivi 已提交
194
	.display.has_gmch = 1, \
195
	.gpu_reset_clobbers_display = true, \
196
	.hws_needs_physical = 1, \
197
	.unfenced_needs_alignment = 1, \
198
	.platform_engine_mask = BIT(RCS0), \
199
	.has_snoop = true, \
200
	.has_coherent_ggtt = false, \
201
	.dma_mask_size = 32, \
202 203
	I845_PIPE_OFFSETS, \
	I845_CURSOR_OFFSETS, \
204
	I9XX_COLORS, \
M
Matthew Auld 已提交
205 206
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
207

208
static const struct intel_device_info i830_info = {
209
	I830_FEATURES,
210
	PLATFORM(INTEL_I830),
211 212
};

213
static const struct intel_device_info i845g_info = {
214
	I845_FEATURES,
215
	PLATFORM(INTEL_I845G),
216 217
};

218
static const struct intel_device_info i85x_info = {
219
	I830_FEATURES,
220
	PLATFORM(INTEL_I85X),
221
	.display.has_fbc = 1,
222 223
};

224
static const struct intel_device_info i865g_info = {
225
	I845_FEATURES,
226
	PLATFORM(INTEL_I865G),
227
	.display.has_fbc = 1,
228 229
};

230
#define GEN3_FEATURES \
231
	GEN(3), \
232
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
233
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B), \
R
Rodrigo Vivi 已提交
234
	.display.has_gmch = 1, \
235
	.gpu_reset_clobbers_display = true, \
236
	.platform_engine_mask = BIT(RCS0), \
237
	.has_snoop = true, \
238
	.has_coherent_ggtt = true, \
239
	.dma_mask_size = 32, \
240 241
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
242
	I9XX_COLORS, \
M
Matthew Auld 已提交
243 244
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
245

246
static const struct intel_device_info i915g_info = {
247
	GEN3_FEATURES,
248
	PLATFORM(INTEL_I915G),
249
	.has_coherent_ggtt = false,
250 251 252
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
253
	.hws_needs_physical = 1,
254
	.unfenced_needs_alignment = 1,
255
};
256

257
static const struct intel_device_info i915gm_info = {
258
	GEN3_FEATURES,
259
	PLATFORM(INTEL_I915GM),
260
	.is_mobile = 1,
261 262 263 264 265
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
	.display.supports_tv = 1,
	.display.has_fbc = 1,
266
	.hws_needs_physical = 1,
267
	.unfenced_needs_alignment = 1,
268
};
269

270
static const struct intel_device_info i945g_info = {
271
	GEN3_FEATURES,
272
	PLATFORM(INTEL_I945G),
273 274 275 276
	.display.has_hotplug = 1,
	.display.cursor_needs_physical = 1,
	.display.has_overlay = 1,
	.display.overlay_needs_physical = 1,
277
	.hws_needs_physical = 1,
278
	.unfenced_needs_alignment = 1,
279
};
280

281
static const struct intel_device_info i945gm_info = {
282
	GEN3_FEATURES,
283 284
	PLATFORM(INTEL_I945GM),
	.is_mobile = 1,
285 286 287 288 289 290
	.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,
291
	.hws_needs_physical = 1,
292
	.unfenced_needs_alignment = 1,
293 294
};

295
static const struct intel_device_info g33_info = {
296
	GEN3_FEATURES,
297
	PLATFORM(INTEL_G33),
298 299
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
300
	.dma_mask_size = 36,
301 302
};

303
static const struct intel_device_info pnv_g_info = {
304 305 306 307
	GEN3_FEATURES,
	PLATFORM(INTEL_PINEVIEW),
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
308
	.dma_mask_size = 36,
309 310
};

311
static const struct intel_device_info pnv_m_info = {
312
	GEN3_FEATURES,
313 314
	PLATFORM(INTEL_PINEVIEW),
	.is_mobile = 1,
315 316
	.display.has_hotplug = 1,
	.display.has_overlay = 1,
317
	.dma_mask_size = 36,
318 319
};

320
#define GEN4_FEATURES \
321
	GEN(4), \
322
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
323
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B), \
324
	.display.has_hotplug = 1, \
R
Rodrigo Vivi 已提交
325
	.display.has_gmch = 1, \
326
	.gpu_reset_clobbers_display = true, \
327
	.platform_engine_mask = BIT(RCS0), \
328
	.has_snoop = true, \
329
	.has_coherent_ggtt = true, \
330
	.dma_mask_size = 36, \
331 332
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
333
	I965_COLORS, \
M
Matthew Auld 已提交
334 335
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
336

337
static const struct intel_device_info i965g_info = {
338
	GEN4_FEATURES,
339
	PLATFORM(INTEL_I965G),
340
	.display.has_overlay = 1,
341
	.hws_needs_physical = 1,
342
	.has_snoop = false,
343 344
};

345
static const struct intel_device_info i965gm_info = {
346
	GEN4_FEATURES,
347
	PLATFORM(INTEL_I965GM),
348 349 350 351
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.has_overlay = 1,
	.display.supports_tv = 1,
352
	.hws_needs_physical = 1,
353
	.has_snoop = false,
354 355
};

356
static const struct intel_device_info g45_info = {
357
	GEN4_FEATURES,
358
	PLATFORM(INTEL_G45),
359
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0),
360
	.gpu_reset_clobbers_display = false,
361 362
};

363
static const struct intel_device_info gm45_info = {
364
	GEN4_FEATURES,
365
	PLATFORM(INTEL_GM45),
366 367 368
	.is_mobile = 1,
	.display.has_fbc = 1,
	.display.supports_tv = 1,
369
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0),
370
	.gpu_reset_clobbers_display = false,
371 372
};

373
#define GEN5_FEATURES \
374
	GEN(5), \
375
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
376
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B), \
377
	.display.has_hotplug = 1, \
378
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0), \
379
	.has_snoop = true, \
380
	.has_coherent_ggtt = true, \
381 382
	/* ilk does support rc6, but we do not implement [power] contexts */ \
	.has_rc6 = 0, \
383
	.dma_mask_size = 36, \
384 385
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
386
	ILK_COLORS, \
M
Matthew Auld 已提交
387 388
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
389

390
static const struct intel_device_info ilk_d_info = {
391
	GEN5_FEATURES,
392
	PLATFORM(INTEL_IRONLAKE),
393 394
};

395
static const struct intel_device_info ilk_m_info = {
396
	GEN5_FEATURES,
397
	PLATFORM(INTEL_IRONLAKE),
398
	.is_mobile = 1,
399
	.has_rps = true,
400
	.display.has_fbc = 1,
401 402
};

403
#define GEN6_FEATURES \
404
	GEN(6), \
405
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B), \
406
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B), \
407 408
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
409
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
410
	.has_coherent_ggtt = true, \
411
	.has_llc = 1, \
412
	.has_rc6 = 1, \
413
	.has_rc6p = 1, \
414
	.has_rps = true, \
415
	.dma_mask_size = 40, \
416 417
	.ppgtt_type = INTEL_PPGTT_ALIASING, \
	.ppgtt_size = 31, \
418 419
	I9XX_PIPE_OFFSETS, \
	I9XX_CURSOR_OFFSETS, \
420
	ILK_COLORS, \
M
Matthew Auld 已提交
421 422
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
423

424 425
#define SNB_D_PLATFORM \
	GEN6_FEATURES, \
426
	PLATFORM(INTEL_SANDYBRIDGE)
427

428
static const struct intel_device_info snb_d_gt1_info = {
429 430
	SNB_D_PLATFORM,
	.gt = 1,
431 432
};

433
static const struct intel_device_info snb_d_gt2_info = {
434 435 436 437 438 439
	SNB_D_PLATFORM,
	.gt = 2,
};

#define SNB_M_PLATFORM \
	GEN6_FEATURES, \
440
	PLATFORM(INTEL_SANDYBRIDGE), \
441 442 443
	.is_mobile = 1


444
static const struct intel_device_info snb_m_gt1_info = {
445 446 447 448
	SNB_M_PLATFORM,
	.gt = 1,
};

449
static const struct intel_device_info snb_m_gt2_info = {
450 451
	SNB_M_PLATFORM,
	.gt = 2,
452 453 454
};

#define GEN7_FEATURES  \
455
	GEN(7), \
456
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), \
457
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | BIT(TRANSCODER_C), \
458 459
	.display.has_hotplug = 1, \
	.display.has_fbc = 1, \
460
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
461
	.has_coherent_ggtt = true, \
462
	.has_llc = 1, \
463
	.has_rc6 = 1, \
464
	.has_rc6p = 1, \
465
	.has_reset_engine = true, \
466
	.has_rps = true, \
467
	.dma_mask_size = 40, \
468
	.ppgtt_type = INTEL_PPGTT_ALIASING, \
469
	.ppgtt_size = 31, \
470 471
	IVB_PIPE_OFFSETS, \
	IVB_CURSOR_OFFSETS, \
472
	IVB_COLORS, \
M
Matthew Auld 已提交
473 474
	GEN_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
475

476 477
#define IVB_D_PLATFORM \
	GEN7_FEATURES, \
478
	PLATFORM(INTEL_IVYBRIDGE), \
479 480
	.has_l3_dpf = 1

481
static const struct intel_device_info ivb_d_gt1_info = {
482 483
	IVB_D_PLATFORM,
	.gt = 1,
484 485
};

486
static const struct intel_device_info ivb_d_gt2_info = {
487 488 489 490 491 492
	IVB_D_PLATFORM,
	.gt = 2,
};

#define IVB_M_PLATFORM \
	GEN7_FEATURES, \
493
	PLATFORM(INTEL_IVYBRIDGE), \
494 495 496
	.is_mobile = 1, \
	.has_l3_dpf = 1

497
static const struct intel_device_info ivb_m_gt1_info = {
498 499 500 501
	IVB_M_PLATFORM,
	.gt = 1,
};

502
static const struct intel_device_info ivb_m_gt2_info = {
503 504
	IVB_M_PLATFORM,
	.gt = 2,
505 506
};

507
static const struct intel_device_info ivb_q_info = {
508
	GEN7_FEATURES,
509
	PLATFORM(INTEL_IVYBRIDGE),
510
	.gt = 2,
511
	.pipe_mask = 0, /* legal, last one wins */
512
	.cpu_transcoder_mask = 0,
513
	.has_l3_dpf = 1,
514 515
};

516
static const struct intel_device_info vlv_info = {
517
	PLATFORM(INTEL_VALLEYVIEW),
518
	GEN(7),
519
	.is_lp = 1,
520
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B),
521
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B),
522 523
	.has_runtime_pm = 1,
	.has_rc6 = 1,
524
	.has_reset_engine = true,
525
	.has_rps = true,
R
Rodrigo Vivi 已提交
526
	.display.has_gmch = 1,
527
	.display.has_hotplug = 1,
528
	.dma_mask_size = 40,
529
	.ppgtt_type = INTEL_PPGTT_ALIASING,
530
	.ppgtt_size = 31,
531
	.has_snoop = true,
532
	.has_coherent_ggtt = false,
533
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0),
534
	.display_mmio_offset = VLV_DISPLAY_BASE,
535 536
	I9XX_PIPE_OFFSETS,
	I9XX_CURSOR_OFFSETS,
537
	I965_COLORS,
538
	GEN_DEFAULT_PAGE_SIZES,
M
Matthew Auld 已提交
539
	GEN_DEFAULT_REGIONS,
540 541
};

542
#define G75_FEATURES  \
543
	GEN7_FEATURES, \
544
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
545 546
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | \
		BIT(TRANSCODER_C) | BIT(TRANSCODER_EDP), \
547
	.display.has_ddi = 1, \
548
	.display.has_fpga_dbg = 1, \
549
	.display.has_psr = 1, \
550
	.display.has_psr_hw_tracking = 1, \
551
	.display.has_dp_mst = 1, \
552
	.has_rc6p = 0 /* RC6p removed-by HSW */, \
553
	HSW_PIPE_OFFSETS, \
554
	.has_runtime_pm = 1
555

556
#define HSW_PLATFORM \
557
	G75_FEATURES, \
558
	PLATFORM(INTEL_HASWELL), \
559 560
	.has_l3_dpf = 1

561
static const struct intel_device_info hsw_gt1_info = {
562 563 564 565
	HSW_PLATFORM,
	.gt = 1,
};

566
static const struct intel_device_info hsw_gt2_info = {
567 568 569 570
	HSW_PLATFORM,
	.gt = 2,
};

571
static const struct intel_device_info hsw_gt3_info = {
572 573
	HSW_PLATFORM,
	.gt = 3,
574 575
};

576 577
#define GEN8_FEATURES \
	G75_FEATURES, \
578
	GEN(8), \
579
	.has_logical_ring_contexts = 1, \
580
	.dma_mask_size = 39, \
581
	.ppgtt_type = INTEL_PPGTT_FULL, \
582
	.ppgtt_size = 48, \
583
	.has_64bit_reloc = 1
584

585
#define BDW_PLATFORM \
586
	GEN8_FEATURES, \
587
	PLATFORM(INTEL_BROADWELL)
588

589
static const struct intel_device_info bdw_gt1_info = {
590 591 592 593
	BDW_PLATFORM,
	.gt = 1,
};

594
static const struct intel_device_info bdw_gt2_info = {
595
	BDW_PLATFORM,
596 597 598
	.gt = 2,
};

599
static const struct intel_device_info bdw_rsvd_info = {
600 601 602 603 604
	BDW_PLATFORM,
	.gt = 3,
	/* According to the device ID those devices are GT3, they were
	 * previously treated as not GT3, keep it like that.
	 */
605 606
};

607
static const struct intel_device_info bdw_gt3_info = {
608
	BDW_PLATFORM,
609
	.gt = 3,
610
	.platform_engine_mask =
611
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
612 613
};

614
static const struct intel_device_info chv_info = {
615
	PLATFORM(INTEL_CHERRYVIEW),
616
	GEN(8),
617
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C),
618
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | BIT(TRANSCODER_C),
619
	.display.has_hotplug = 1,
620
	.is_lp = 1,
621
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0),
622
	.has_64bit_reloc = 1,
623
	.has_runtime_pm = 1,
624
	.has_rc6 = 1,
625
	.has_rps = true,
626
	.has_logical_ring_contexts = 1,
R
Rodrigo Vivi 已提交
627
	.display.has_gmch = 1,
628
	.dma_mask_size = 39,
629
	.ppgtt_type = INTEL_PPGTT_FULL,
630
	.ppgtt_size = 32,
631
	.has_reset_engine = 1,
632
	.has_snoop = true,
633
	.has_coherent_ggtt = false,
634
	.display_mmio_offset = VLV_DISPLAY_BASE,
635 636
	CHV_PIPE_OFFSETS,
	CHV_CURSOR_OFFSETS,
637
	CHV_COLORS,
638
	GEN_DEFAULT_PAGE_SIZES,
M
Matthew Auld 已提交
639
	GEN_DEFAULT_REGIONS,
640 641
};

642
#define GEN9_DEFAULT_PAGE_SIZES \
643
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
644
		      I915_GTT_PAGE_SIZE_64K
645

646 647
#define GEN9_FEATURES \
	GEN8_FEATURES, \
648
	GEN(9), \
649
	GEN9_DEFAULT_PAGE_SIZES, \
650
	.display.has_dmc = 1, \
651
	.has_gt_uc = 1, \
652
	.display.has_hdcp = 1, \
653
	.display.has_ipc = 1, \
654
	.dbuf.size = 896 - 4, /* 4 blocks for bypass path allocation */ \
655
	.dbuf.slice_mask = BIT(DBUF_S1)
656

657 658
#define SKL_PLATFORM \
	GEN9_FEATURES, \
659
	PLATFORM(INTEL_SKYLAKE)
660

661
static const struct intel_device_info skl_gt1_info = {
662
	SKL_PLATFORM,
663
	.gt = 1,
664 665
};

666
static const struct intel_device_info skl_gt2_info = {
667
	SKL_PLATFORM,
668 669 670 671 672
	.gt = 2,
};

#define SKL_GT3_PLUS_PLATFORM \
	SKL_PLATFORM, \
673
	.platform_engine_mask = \
674
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1)
675 676


677
static const struct intel_device_info skl_gt3_info = {
678 679 680 681
	SKL_GT3_PLUS_PLATFORM,
	.gt = 3,
};

682
static const struct intel_device_info skl_gt4_info = {
683 684
	SKL_GT3_PLUS_PLATFORM,
	.gt = 4,
685 686
};

687
#define GEN9_LP_FEATURES \
688
	GEN(9), \
689
	.is_lp = 1, \
690
	.dbuf.slice_mask = BIT(DBUF_S1), \
691
	.display.has_hotplug = 1, \
692
	.platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
693
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C), \
694 695 696
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | \
		BIT(TRANSCODER_C) | BIT(TRANSCODER_EDP) | \
		BIT(TRANSCODER_DSI_A) | BIT(TRANSCODER_DSI_C), \
697
	.has_64bit_reloc = 1, \
698
	.display.has_ddi = 1, \
699
	.display.has_fpga_dbg = 1, \
700
	.display.has_fbc = 1, \
701
	.display.has_hdcp = 1, \
702
	.display.has_psr = 1, \
703
	.display.has_psr_hw_tracking = 1, \
704
	.has_runtime_pm = 1, \
705
	.display.has_dmc = 1, \
706
	.has_rc6 = 1, \
707
	.has_rps = true, \
708
	.display.has_dp_mst = 1, \
709
	.has_logical_ring_contexts = 1, \
710
	.has_gt_uc = 1, \
711
	.dma_mask_size = 39, \
712
	.ppgtt_type = INTEL_PPGTT_FULL, \
713
	.ppgtt_size = 48, \
714
	.has_reset_engine = 1, \
715
	.has_snoop = true, \
716
	.has_coherent_ggtt = false, \
717
	.display.has_ipc = 1, \
718
	HSW_PIPE_OFFSETS, \
719
	IVB_CURSOR_OFFSETS, \
720
	IVB_COLORS, \
M
Matthew Auld 已提交
721 722
	GEN9_DEFAULT_PAGE_SIZES, \
	GEN_DEFAULT_REGIONS
723

724
static const struct intel_device_info bxt_info = {
725
	GEN9_LP_FEATURES,
726
	PLATFORM(INTEL_BROXTON),
727
	.dbuf.size = 512 - 4, /* 4 blocks for bypass path allocation */
728 729
};

730
static const struct intel_device_info glk_info = {
731
	GEN9_LP_FEATURES,
732
	PLATFORM(INTEL_GEMINILAKE),
733
	.display.ver = 10,
734
	.dbuf.size = 1024 - 4, /* 4 blocks for bypass path allocation */
R
Rodrigo Vivi 已提交
735
	GLK_COLORS,
736 737
};

738
#define KBL_PLATFORM \
739
	GEN9_FEATURES, \
740
	PLATFORM(INTEL_KABYLAKE)
741

742
static const struct intel_device_info kbl_gt1_info = {
743
	KBL_PLATFORM,
744 745 746
	.gt = 1,
};

747
static const struct intel_device_info kbl_gt2_info = {
748 749
	KBL_PLATFORM,
	.gt = 2,
750 751
};

752
static const struct intel_device_info kbl_gt3_info = {
753
	KBL_PLATFORM,
754
	.gt = 3,
755
	.platform_engine_mask =
756
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
757 758
};

759
#define CFL_PLATFORM \
760
	GEN9_FEATURES, \
761
	PLATFORM(INTEL_COFFEELAKE)
762

763
static const struct intel_device_info cfl_gt1_info = {
764 765 766 767
	CFL_PLATFORM,
	.gt = 1,
};

768
static const struct intel_device_info cfl_gt2_info = {
769
	CFL_PLATFORM,
770
	.gt = 2,
771 772
};

773
static const struct intel_device_info cfl_gt3_info = {
774
	CFL_PLATFORM,
775
	.gt = 3,
776
	.platform_engine_mask =
777
		BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
778 779
};

780 781 782 783 784 785 786 787 788 789 790 791 792 793
#define CML_PLATFORM \
	GEN9_FEATURES, \
	PLATFORM(INTEL_COMETLAKE)

static const struct intel_device_info cml_gt1_info = {
	CML_PLATFORM,
	.gt = 1,
};

static const struct intel_device_info cml_gt2_info = {
	CML_PLATFORM,
	.gt = 2,
};

794 795
#define GEN10_FEATURES \
	GEN9_FEATURES, \
796
	GEN(10), \
797
	.dbuf.size = 1024 - 4, /* 4 blocks for bypass path allocation */ \
798
	.display.has_dsc = 1, \
799
	.has_coherent_ggtt = false, \
R
Rodrigo Vivi 已提交
800
	GLK_COLORS
801

802
static const struct intel_device_info cnl_info = {
803
	GEN10_FEATURES,
804
	PLATFORM(INTEL_CANNONLAKE),
805
	.gt = 2,
806 807
};

808 809 810 811 812
#define GEN11_DEFAULT_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M

813 814
#define GEN11_FEATURES \
	GEN10_FEATURES, \
815
	GEN11_DEFAULT_PAGE_SIZES, \
816
	.abox_mask = BIT(0), \
817 818 819
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | \
		BIT(TRANSCODER_C) | BIT(TRANSCODER_EDP) | \
		BIT(TRANSCODER_DSI_0) | BIT(TRANSCODER_DSI_1), \
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
	.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, \
	}, \
836
	GEN(11), \
837
	.dbuf.size = 2048, \
838
	.dbuf.slice_mask = BIT(DBUF_S1) | BIT(DBUF_S2), \
839
	.has_logical_ring_elsq = 1, \
840
	.color = { .degamma_lut_size = 33, .gamma_lut_size = 262145 }
841

842
static const struct intel_device_info icl_info = {
843
	GEN11_FEATURES,
844
	PLATFORM(INTEL_ICELAKE),
845
	.platform_engine_mask =
846
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
847 848
};

849
static const struct intel_device_info ehl_info = {
850
	GEN11_FEATURES,
851
	PLATFORM(INTEL_ELKHARTLAKE),
852
	.require_force_probe = 1,
853
	.platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
854 855 856
	.ppgtt_size = 36,
};

857 858 859 860 861 862 863 864
static const struct intel_device_info jsl_info = {
	GEN11_FEATURES,
	PLATFORM(INTEL_JASPERLAKE),
	.require_force_probe = 1,
	.platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
	.ppgtt_size = 36,
};

865 866 867
#define GEN12_FEATURES \
	GEN11_FEATURES, \
	GEN(12), \
868
	.abox_mask = GENMASK(2, 1), \
869 870 871 872
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), \
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) | \
		BIT(TRANSCODER_C) | BIT(TRANSCODER_D) | \
		BIT(TRANSCODER_DSI_0) | BIT(TRANSCODER_DSI_1), \
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
	.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, \
888
	}, \
889
	TGL_CURSOR_OFFSETS, \
890 891
	.has_global_mocs = 1, \
	.display.has_dsb = 1
892

893
static const struct intel_device_info tgl_info = {
894 895
	GEN12_FEATURES,
	PLATFORM(INTEL_TIGERLAKE),
896
	.display.has_modular_fia = 1,
897
	.platform_engine_mask =
898 899 900
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
};

901 902 903
static const struct intel_device_info rkl_info = {
	GEN12_FEATURES,
	PLATFORM(INTEL_ROCKETLAKE),
904
	.abox_mask = BIT(0),
905
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C),
906 907
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) |
		BIT(TRANSCODER_C),
M
Matt Roper 已提交
908
	.display.has_hti = 1,
909
	.display.has_psr_hw_tracking = 0,
910
	.platform_engine_mask =
911 912 913
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0),
};

914
#define DGFX_FEATURES \
915
	.memory_regions = REGION_SMEM | REGION_LMEM | REGION_STOLEN_LMEM, \
916
	.has_master_unit_irq = 1, \
917 918
	.has_llc = 0, \
	.has_snoop = 1, \
919 920
	.is_dgfx = 1

921
static const struct intel_device_info dg1_info __maybe_unused = {
922 923
	GEN12_FEATURES,
	DGFX_FEATURES,
924 925 926 927 928 929
	PLATFORM(INTEL_DG1),
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D),
	.require_force_probe = 1,
	.platform_engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) |
		BIT(VCS0) | BIT(VCS2),
930 931
	/* Wa_16011227922 */
	.ppgtt_size = 47,
932 933
};

934 935 936 937 938 939 940 941 942
static const struct intel_device_info adl_s_info = {
	GEN12_FEATURES,
	PLATFORM(INTEL_ALDERLAKE_S),
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D),
	.require_force_probe = 1,
	.display.has_hti = 1,
	.display.has_psr_hw_tracking = 0,
	.platform_engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
943
	.dma_mask_size = 39,
944 945
};

946 947 948 949 950 951 952 953 954 955
#define XE_LPD_FEATURES \
	.display.ver = 13,						\
	.display.has_psr_hw_tracking = 0,				\
	.abox_mask = GENMASK(1, 0),					\
	.pipe_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C) | BIT(PIPE_D), \
	.cpu_transcoder_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) |	\
		BIT(TRANSCODER_C) | BIT(TRANSCODER_D),			\
	.dbuf.size = 4096,						\
	.dbuf.slice_mask = BIT(DBUF_S1) | BIT(DBUF_S2) | BIT(DBUF_S3) | BIT(DBUF_S4)

956 957 958 959
static const struct intel_device_info adl_p_info = {
	GEN12_FEATURES,
	XE_LPD_FEATURES,
	PLATFORM(INTEL_ALDERLAKE_P),
960
	.has_cdclk_crawl = 1,
961
	.require_force_probe = 1,
962
	.display.has_modular_fia = 1,
963 964 965 966 967 968
	.platform_engine_mask =
		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
	.ppgtt_size = 48,
	.dma_mask_size = 39,
};

969
#undef GEN
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993

#define XE_HP_PAGE_SIZES \
	.page_sizes = I915_GTT_PAGE_SIZE_4K | \
		      I915_GTT_PAGE_SIZE_64K | \
		      I915_GTT_PAGE_SIZE_2M

#define XE_HP_FEATURES \
	.graphics_ver = 12, \
	.graphics_rel = 50, \
	XE_HP_PAGE_SIZES, \
	.dma_mask_size = 46, \
	.has_64bit_reloc = 1, \
	.has_global_mocs = 1, \
	.has_gt_uc = 1, \
	.has_llc = 1, \
	.has_logical_ring_contexts = 1, \
	.has_logical_ring_elsq = 1, \
	.has_rc6 = 1, \
	.has_reset_engine = 1, \
	.has_rps = 1, \
	.has_runtime_pm = 1, \
	.ppgtt_size = 48, \
	.ppgtt_type = INTEL_PPGTT_FULL

994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007
#define XE_HPM_FEATURES \
	.media_ver = 12, \
	.media_rel = 50

__maybe_unused
static const struct intel_device_info xehpsdv_info = {
	XE_HP_FEATURES,
	XE_HPM_FEATURES,
	DGFX_FEATURES,
	PLATFORM(INTEL_XEHPSDV),
	.display = { },
	.pipe_mask = 0,
	.platform_engine_mask =
		BIT(RCS0) | BIT(BCS0) |
1008 1009 1010
		BIT(VECS0) | BIT(VECS1) | BIT(VECS2) | BIT(VECS3) |
		BIT(VCS0) | BIT(VCS1) | BIT(VCS2) | BIT(VCS3) |
		BIT(VCS4) | BIT(VCS5) | BIT(VCS6) | BIT(VCS7),
1011 1012 1013
	.require_force_probe = 1,
};

M
Matt Roper 已提交
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
__maybe_unused
static const struct intel_device_info dg2_info = {
	XE_HP_FEATURES,
	XE_HPM_FEATURES,
	XE_LPD_FEATURES,
	DGFX_FEATURES,
	.graphics_rel = 55,
	.media_rel = 55,
	PLATFORM(INTEL_DG2),
	.platform_engine_mask =
		BIT(RCS0) | BIT(BCS0) |
		BIT(VECS0) | BIT(VECS1) |
		BIT(VCS0) | BIT(VCS2),
	.require_force_probe = 1,
};

1030
#undef PLATFORM
1031

1032 1033 1034 1035 1036 1037 1038
/*
 * 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[] = {
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
	INTEL_I830_IDS(&i830_info),
	INTEL_I845G_IDS(&i845g_info),
	INTEL_I85X_IDS(&i85x_info),
	INTEL_I865G_IDS(&i865g_info),
	INTEL_I915G_IDS(&i915g_info),
	INTEL_I915GM_IDS(&i915gm_info),
	INTEL_I945G_IDS(&i945g_info),
	INTEL_I945GM_IDS(&i945gm_info),
	INTEL_I965G_IDS(&i965g_info),
	INTEL_G33_IDS(&g33_info),
	INTEL_I965GM_IDS(&i965gm_info),
	INTEL_GM45_IDS(&gm45_info),
	INTEL_G45_IDS(&g45_info),
	INTEL_PINEVIEW_G_IDS(&pnv_g_info),
	INTEL_PINEVIEW_M_IDS(&pnv_m_info),
	INTEL_IRONLAKE_D_IDS(&ilk_d_info),
	INTEL_IRONLAKE_M_IDS(&ilk_m_info),
	INTEL_SNB_D_GT1_IDS(&snb_d_gt1_info),
	INTEL_SNB_D_GT2_IDS(&snb_d_gt2_info),
	INTEL_SNB_M_GT1_IDS(&snb_m_gt1_info),
	INTEL_SNB_M_GT2_IDS(&snb_m_gt2_info),
	INTEL_IVB_Q_IDS(&ivb_q_info), /* must be first IVB */
	INTEL_IVB_M_GT1_IDS(&ivb_m_gt1_info),
	INTEL_IVB_M_GT2_IDS(&ivb_m_gt2_info),
	INTEL_IVB_D_GT1_IDS(&ivb_d_gt1_info),
	INTEL_IVB_D_GT2_IDS(&ivb_d_gt2_info),
	INTEL_HSW_GT1_IDS(&hsw_gt1_info),
	INTEL_HSW_GT2_IDS(&hsw_gt2_info),
	INTEL_HSW_GT3_IDS(&hsw_gt3_info),
	INTEL_VLV_IDS(&vlv_info),
	INTEL_BDW_GT1_IDS(&bdw_gt1_info),
	INTEL_BDW_GT2_IDS(&bdw_gt2_info),
	INTEL_BDW_GT3_IDS(&bdw_gt3_info),
	INTEL_BDW_RSVD_IDS(&bdw_rsvd_info),
	INTEL_CHV_IDS(&chv_info),
	INTEL_SKL_GT1_IDS(&skl_gt1_info),
	INTEL_SKL_GT2_IDS(&skl_gt2_info),
	INTEL_SKL_GT3_IDS(&skl_gt3_info),
	INTEL_SKL_GT4_IDS(&skl_gt4_info),
	INTEL_BXT_IDS(&bxt_info),
	INTEL_GLK_IDS(&glk_info),
	INTEL_KBL_GT1_IDS(&kbl_gt1_info),
	INTEL_KBL_GT2_IDS(&kbl_gt2_info),
	INTEL_KBL_GT3_IDS(&kbl_gt3_info),
	INTEL_KBL_GT4_IDS(&kbl_gt3_info),
	INTEL_AML_KBL_GT2_IDS(&kbl_gt2_info),
	INTEL_CFL_S_GT1_IDS(&cfl_gt1_info),
	INTEL_CFL_S_GT2_IDS(&cfl_gt2_info),
	INTEL_CFL_H_GT1_IDS(&cfl_gt1_info),
	INTEL_CFL_H_GT2_IDS(&cfl_gt2_info),
	INTEL_CFL_U_GT2_IDS(&cfl_gt2_info),
	INTEL_CFL_U_GT3_IDS(&cfl_gt3_info),
	INTEL_WHL_U_GT1_IDS(&cfl_gt1_info),
	INTEL_WHL_U_GT2_IDS(&cfl_gt2_info),
	INTEL_AML_CFL_GT2_IDS(&cfl_gt2_info),
	INTEL_WHL_U_GT3_IDS(&cfl_gt3_info),
1095 1096 1097 1098
	INTEL_CML_GT1_IDS(&cml_gt1_info),
	INTEL_CML_GT2_IDS(&cml_gt2_info),
	INTEL_CML_U_GT1_IDS(&cml_gt1_info),
	INTEL_CML_U_GT2_IDS(&cml_gt2_info),
1099 1100 1101
	INTEL_CNL_IDS(&cnl_info),
	INTEL_ICL_11_IDS(&icl_info),
	INTEL_EHL_IDS(&ehl_info),
1102
	INTEL_JSL_IDS(&jsl_info),
1103
	INTEL_TGL_12_IDS(&tgl_info),
1104
	INTEL_RKL_IDS(&rkl_info),
1105
	INTEL_ADLS_IDS(&adl_s_info),
1106
	INTEL_ADLP_IDS(&adl_p_info),
1107 1108 1109 1110
	{0, 0, 0}
};
MODULE_DEVICE_TABLE(pci, pciidlist);

1111 1112
static void i915_pci_remove(struct pci_dev *pdev)
{
1113
	struct drm_i915_private *i915;
1114

1115 1116
	i915 = pci_get_drvdata(pdev);
	if (!i915) /* driver load aborted, nothing to cleanup */
1117
		return;
1118

1119
	i915_driver_remove(i915);
1120
	pci_set_drvdata(pdev, NULL);
1121 1122
}

1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
/* 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;

	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;
}

1154 1155 1156 1157
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;
1158
	int err;
1159

1160 1161
	if (intel_info->require_force_probe &&
	    !force_probe(pdev->device, i915_modparams.force_probe)) {
1162
		dev_info(&pdev->dev,
1163
			 "Your graphics device %04x is not properly supported by the driver in this\n"
1164 1165 1166 1167
			 "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);
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
		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;

1186
	err = i915_driver_probe(pdev, ent);
1187 1188
	if (err)
		return err;
1189

1190
	if (i915_inject_probe_failure(pci_get_drvdata(pdev))) {
1191 1192 1193 1194
		i915_pci_remove(pdev);
		return -ENODEV;
	}

1195 1196 1197 1198 1199
	err = i915_live_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}
1200

1201 1202 1203 1204 1205 1206
	err = i915_perf_selftests(pdev);
	if (err) {
		i915_pci_remove(pdev);
		return err > 0 ? -ENOTTY : err;
	}

1207
	return 0;
1208 1209
}

1210 1211 1212 1213 1214 1215 1216
static void i915_pci_shutdown(struct pci_dev *pdev)
{
	struct drm_i915_private *i915 = pci_get_drvdata(pdev);

	i915_driver_shutdown(i915);
}

1217
static int i915_check_nomodeset(void)
1218 1219 1220 1221 1222 1223 1224 1225 1226
{
	bool use_kms = true;

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

1227
	if (i915_modparams.modeset == 0)
1228 1229
		use_kms = false;

1230
	if (vgacon_text_force() && i915_modparams.modeset == -1)
1231 1232 1233 1234 1235
		use_kms = false;

	if (!use_kms) {
		/* Silently fail loading to not upset userspace. */
		DRM_DEBUG_DRIVER("KMS disabled.\n");
1236
		return 1;
1237 1238
	}

1239 1240
	return 0;
}
1241

1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
static struct pci_driver i915_pci_driver = {
	.name = DRIVER_NAME,
	.id_table = pciidlist,
	.probe = i915_pci_probe,
	.remove = i915_pci_remove,
	.shutdown = i915_pci_shutdown,
	.driver.pm = &i915_pm_ops,
};

static int i915_register_pci_driver(void)
{
	return pci_register_driver(&i915_pci_driver);
}

static void i915_unregister_pci_driver(void)
{
	pci_unregister_driver(&i915_pci_driver);
}

static const struct {
   int (*init)(void);
   void (*exit)(void);
} init_funcs[] = {
1265
	{ i915_check_nomodeset, NULL },
1266
	{ i915_active_module_init, i915_active_module_exit },
1267
	{ i915_buddy_module_init, i915_buddy_module_exit },
1268
	{ i915_context_module_init, i915_context_module_exit },
1269
	{ i915_gem_context_module_init, i915_gem_context_module_exit },
1270
	{ i915_objects_module_init, i915_objects_module_exit },
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
	{ i915_globals_init, i915_globals_exit },
	{ i915_mock_selftests, NULL },
	{ i915_pmu_init, i915_pmu_exit },
	{ i915_register_pci_driver, i915_unregister_pci_driver },
	{ i915_perf_sysctl_register, i915_perf_sysctl_unregister },
};
static int init_progress;

static int __init i915_init(void)
{
	int err, i;

	for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
		err = init_funcs[i].init();
		if (err < 0) {
			while (i--) {
				if (init_funcs[i].exit)
					init_funcs[i].exit();
			}
			return err;
		} else if (err > 0) {
			/*
			 * Early-exit success is reserved for things which
			 * don't have an exit() function because we have no
			 * idea how far they got or how to partially tear
			 * them down.
			 */
			WARN_ON(init_funcs[i].exit);

			/*
			 * We don't want to advertise devices with an only
			 * partially initialized driver.
			 */
			WARN_ON(i915_pci_driver.driver.owner);
			break;
		}
1307
	}
1308

1309 1310
	init_progress = i;

1311
	return 0;
1312 1313 1314 1315
}

static void __exit i915_exit(void)
{
1316
	int i;
1317

1318 1319 1320 1321 1322
	for (i = init_progress - 1; i >= 0; i--) {
		GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
		if (init_funcs[i].exit)
			init_funcs[i].exit();
	}
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
}

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