2 * Copyright © 2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include <linux/console.h>
26 #include <linux/vgaarb.h>
27 #include <linux/vga_switcheroo.h>
30 #include "i915_selftest.h"
32 #define PLATFORM(x) .platform = (x), .platform_mask = BIT(x)
33 #define GEN(x) .gen = (x), .gen_mask = BIT((x) - 1)
35 #define GEN_DEFAULT_PIPEOFFSETS \
36 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
37 PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
38 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
39 TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
40 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
42 #define GEN_CHV_PIPEOFFSETS \
43 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
44 CHV_PIPE_C_OFFSET }, \
45 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
46 CHV_TRANSCODER_C_OFFSET, }, \
47 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
48 CHV_PALETTE_C_OFFSET }
50 #define CURSOR_OFFSETS \
51 .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
53 #define IVB_CURSOR_OFFSETS \
54 .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
57 .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
59 .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
61 .color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
63 /* Keep in gen based order, and chronological order within a gen */
65 #define GEN_DEFAULT_PAGE_SIZES \
66 .page_sizes = I915_GTT_PAGE_SIZE_4K
68 #define GEN2_FEATURES \
71 .has_overlay = 1, .overlay_needs_physical = 1, \
72 .has_gmch_display = 1, \
73 .hws_needs_physical = 1, \
74 .unfenced_needs_alignment = 1, \
75 .ring_mask = RENDER_RING, \
77 GEN_DEFAULT_PIPEOFFSETS, \
78 GEN_DEFAULT_PAGE_SIZES, \
81 static const struct intel_device_info intel_i830_info
= {
84 .is_mobile
= 1, .cursor_needs_physical
= 1,
85 .num_pipes
= 2, /* legal, last one wins */
88 static const struct intel_device_info intel_i845g_info
= {
90 PLATFORM(INTEL_I845G
),
93 static const struct intel_device_info intel_i85x_info
= {
97 .num_pipes
= 2, /* legal, last one wins */
98 .cursor_needs_physical
= 1,
102 static const struct intel_device_info intel_i865g_info
= {
104 PLATFORM(INTEL_I865G
),
107 #define GEN3_FEATURES \
110 .has_gmch_display = 1, \
111 .ring_mask = RENDER_RING, \
113 GEN_DEFAULT_PIPEOFFSETS, \
114 GEN_DEFAULT_PAGE_SIZES, \
117 static const struct intel_device_info intel_i915g_info
= {
119 PLATFORM(INTEL_I915G
),
120 .cursor_needs_physical
= 1,
121 .has_overlay
= 1, .overlay_needs_physical
= 1,
122 .hws_needs_physical
= 1,
123 .unfenced_needs_alignment
= 1,
126 static const struct intel_device_info intel_i915gm_info
= {
128 PLATFORM(INTEL_I915GM
),
130 .cursor_needs_physical
= 1,
131 .has_overlay
= 1, .overlay_needs_physical
= 1,
134 .hws_needs_physical
= 1,
135 .unfenced_needs_alignment
= 1,
138 static const struct intel_device_info intel_i945g_info
= {
140 PLATFORM(INTEL_I945G
),
141 .has_hotplug
= 1, .cursor_needs_physical
= 1,
142 .has_overlay
= 1, .overlay_needs_physical
= 1,
143 .hws_needs_physical
= 1,
144 .unfenced_needs_alignment
= 1,
147 static const struct intel_device_info intel_i945gm_info
= {
149 PLATFORM(INTEL_I945GM
),
151 .has_hotplug
= 1, .cursor_needs_physical
= 1,
152 .has_overlay
= 1, .overlay_needs_physical
= 1,
155 .hws_needs_physical
= 1,
156 .unfenced_needs_alignment
= 1,
159 static const struct intel_device_info intel_g33_info
= {
166 static const struct intel_device_info intel_pineview_info
= {
168 PLATFORM(INTEL_PINEVIEW
),
174 #define GEN4_FEATURES \
178 .has_gmch_display = 1, \
179 .ring_mask = RENDER_RING, \
181 GEN_DEFAULT_PIPEOFFSETS, \
182 GEN_DEFAULT_PAGE_SIZES, \
185 static const struct intel_device_info intel_i965g_info
= {
187 PLATFORM(INTEL_I965G
),
189 .hws_needs_physical
= 1,
193 static const struct intel_device_info intel_i965gm_info
= {
195 PLATFORM(INTEL_I965GM
),
196 .is_mobile
= 1, .has_fbc
= 1,
199 .hws_needs_physical
= 1,
203 static const struct intel_device_info intel_g45_info
= {
206 .ring_mask
= RENDER_RING
| BSD_RING
,
209 static const struct intel_device_info intel_gm45_info
= {
211 PLATFORM(INTEL_GM45
),
212 .is_mobile
= 1, .has_fbc
= 1,
214 .ring_mask
= RENDER_RING
| BSD_RING
,
217 #define GEN5_FEATURES \
221 .ring_mask = RENDER_RING | BSD_RING, \
223 /* ilk does support rc6, but we do not implement [power] contexts */ \
225 GEN_DEFAULT_PIPEOFFSETS, \
226 GEN_DEFAULT_PAGE_SIZES, \
229 static const struct intel_device_info intel_ironlake_d_info
= {
231 PLATFORM(INTEL_IRONLAKE
),
234 static const struct intel_device_info intel_ironlake_m_info
= {
236 PLATFORM(INTEL_IRONLAKE
),
237 .is_mobile
= 1, .has_fbc
= 1,
240 #define GEN6_FEATURES \
245 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
249 .has_aliasing_ppgtt = 1, \
250 GEN_DEFAULT_PIPEOFFSETS, \
251 GEN_DEFAULT_PAGE_SIZES, \
254 #define SNB_D_PLATFORM \
256 PLATFORM(INTEL_SANDYBRIDGE)
258 static const struct intel_device_info intel_sandybridge_d_gt1_info
= {
263 static const struct intel_device_info intel_sandybridge_d_gt2_info
= {
268 #define SNB_M_PLATFORM \
270 PLATFORM(INTEL_SANDYBRIDGE), \
274 static const struct intel_device_info intel_sandybridge_m_gt1_info
= {
279 static const struct intel_device_info intel_sandybridge_m_gt2_info
= {
284 #define GEN7_FEATURES \
289 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
293 .has_aliasing_ppgtt = 1, \
294 .has_full_ppgtt = 1, \
295 GEN_DEFAULT_PIPEOFFSETS, \
296 GEN_DEFAULT_PAGE_SIZES, \
299 #define IVB_D_PLATFORM \
301 PLATFORM(INTEL_IVYBRIDGE), \
304 static const struct intel_device_info intel_ivybridge_d_gt1_info
= {
309 static const struct intel_device_info intel_ivybridge_d_gt2_info
= {
314 #define IVB_M_PLATFORM \
316 PLATFORM(INTEL_IVYBRIDGE), \
320 static const struct intel_device_info intel_ivybridge_m_gt1_info
= {
325 static const struct intel_device_info intel_ivybridge_m_gt2_info
= {
330 static const struct intel_device_info intel_ivybridge_q_info
= {
332 PLATFORM(INTEL_IVYBRIDGE
),
334 .num_pipes
= 0, /* legal, last one wins */
338 static const struct intel_device_info intel_valleyview_info
= {
339 PLATFORM(INTEL_VALLEYVIEW
),
345 .has_gmch_display
= 1,
347 .has_aliasing_ppgtt
= 1,
350 .ring_mask
= RENDER_RING
| BSD_RING
| BLT_RING
,
351 .display_mmio_offset
= VLV_DISPLAY_BASE
,
352 GEN_DEFAULT_PAGE_SIZES
,
353 GEN_DEFAULT_PIPEOFFSETS
,
357 #define G75_FEATURES \
359 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
363 .has_resource_streamer = 1, \
365 .has_rc6p = 0 /* RC6p removed-by HSW */, \
368 #define HSW_PLATFORM \
370 PLATFORM(INTEL_HASWELL), \
373 static const struct intel_device_info intel_haswell_gt1_info
= {
378 static const struct intel_device_info intel_haswell_gt2_info
= {
383 static const struct intel_device_info intel_haswell_gt3_info
= {
388 #define GEN8_FEATURES \
392 .page_sizes = I915_GTT_PAGE_SIZE_4K | \
393 I915_GTT_PAGE_SIZE_2M, \
394 .has_logical_ring_contexts = 1, \
395 .has_full_48bit_ppgtt = 1, \
396 .has_64bit_reloc = 1, \
397 .has_reset_engine = 1
399 #define BDW_PLATFORM \
401 PLATFORM(INTEL_BROADWELL)
403 static const struct intel_device_info intel_broadwell_gt1_info
= {
408 static const struct intel_device_info intel_broadwell_gt2_info
= {
413 static const struct intel_device_info intel_broadwell_rsvd_info
= {
416 /* According to the device ID those devices are GT3, they were
417 * previously treated as not GT3, keep it like that.
421 static const struct intel_device_info intel_broadwell_gt3_info
= {
424 .ring_mask
= RENDER_RING
| BSD_RING
| BLT_RING
| VEBOX_RING
| BSD2_RING
,
427 static const struct intel_device_info intel_cherryview_info
= {
428 PLATFORM(INTEL_CHERRYVIEW
),
433 .ring_mask
= RENDER_RING
| BSD_RING
| BLT_RING
| VEBOX_RING
,
434 .has_64bit_reloc
= 1,
436 .has_resource_streamer
= 1,
438 .has_logical_ring_contexts
= 1,
439 .has_gmch_display
= 1,
440 .has_aliasing_ppgtt
= 1,
442 .has_reset_engine
= 1,
444 .display_mmio_offset
= VLV_DISPLAY_BASE
,
445 GEN_DEFAULT_PAGE_SIZES
,
451 #define GEN9_DEFAULT_PAGE_SIZES \
452 .page_sizes = I915_GTT_PAGE_SIZE_4K | \
453 I915_GTT_PAGE_SIZE_64K | \
454 I915_GTT_PAGE_SIZE_2M
456 #define GEN9_FEATURES \
459 GEN9_DEFAULT_PAGE_SIZES, \
460 .has_logical_ring_preemption = 1, \
466 #define SKL_PLATFORM \
468 PLATFORM(INTEL_SKYLAKE)
470 static const struct intel_device_info intel_skylake_gt1_info
= {
475 static const struct intel_device_info intel_skylake_gt2_info
= {
480 #define SKL_GT3_PLUS_PLATFORM \
482 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING
485 static const struct intel_device_info intel_skylake_gt3_info
= {
486 SKL_GT3_PLUS_PLATFORM
,
490 static const struct intel_device_info intel_skylake_gt4_info
= {
491 SKL_GT3_PLUS_PLATFORM
,
495 #define GEN9_LP_FEATURES \
499 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
501 .has_64bit_reloc = 1, \
506 .has_runtime_pm = 1, \
507 .has_pooled_eu = 0, \
509 .has_resource_streamer = 1, \
512 .has_logical_ring_contexts = 1, \
513 .has_logical_ring_preemption = 1, \
515 .has_aliasing_ppgtt = 1, \
516 .has_full_ppgtt = 1, \
517 .has_full_48bit_ppgtt = 1, \
518 .has_reset_engine = 1, \
521 GEN9_DEFAULT_PAGE_SIZES, \
522 GEN_DEFAULT_PIPEOFFSETS, \
523 IVB_CURSOR_OFFSETS, \
526 static const struct intel_device_info intel_broxton_info
= {
528 PLATFORM(INTEL_BROXTON
),
532 static const struct intel_device_info intel_geminilake_info
= {
534 PLATFORM(INTEL_GEMINILAKE
),
539 #define KBL_PLATFORM \
541 PLATFORM(INTEL_KABYLAKE)
543 static const struct intel_device_info intel_kabylake_gt1_info
= {
548 static const struct intel_device_info intel_kabylake_gt2_info
= {
553 static const struct intel_device_info intel_kabylake_gt3_info
= {
556 .ring_mask
= RENDER_RING
| BSD_RING
| BLT_RING
| VEBOX_RING
| BSD2_RING
,
559 #define CFL_PLATFORM \
561 PLATFORM(INTEL_COFFEELAKE)
563 static const struct intel_device_info intel_coffeelake_gt1_info
= {
568 static const struct intel_device_info intel_coffeelake_gt2_info
= {
573 static const struct intel_device_info intel_coffeelake_gt3_info
= {
576 .ring_mask
= RENDER_RING
| BSD_RING
| BLT_RING
| VEBOX_RING
| BSD2_RING
,
579 #define GEN10_FEATURES \
585 static const struct intel_device_info intel_cannonlake_info
= {
587 PLATFORM(INTEL_CANNONLAKE
),
591 #define GEN11_FEATURES \
595 .has_logical_ring_elsq = 1
597 static const struct intel_device_info intel_icelake_11_info
= {
599 PLATFORM(INTEL_ICELAKE
),
600 .is_alpha_support
= 1,
601 .has_resource_streamer
= 0,
602 .ring_mask
= RENDER_RING
| BLT_RING
| VEBOX_RING
| BSD_RING
| BSD3_RING
,
609 * Make sure any device matches here are from most specific to most
610 * general. For example, since the Quanta match is based on the subsystem
611 * and subvendor IDs, we need it to come before the more general IVB
612 * PCI ID matches, otherwise we'll use the wrong info struct above.
614 static const struct pci_device_id pciidlist
[] = {
615 INTEL_I830_IDS(&intel_i830_info
),
616 INTEL_I845G_IDS(&intel_i845g_info
),
617 INTEL_I85X_IDS(&intel_i85x_info
),
618 INTEL_I865G_IDS(&intel_i865g_info
),
619 INTEL_I915G_IDS(&intel_i915g_info
),
620 INTEL_I915GM_IDS(&intel_i915gm_info
),
621 INTEL_I945G_IDS(&intel_i945g_info
),
622 INTEL_I945GM_IDS(&intel_i945gm_info
),
623 INTEL_I965G_IDS(&intel_i965g_info
),
624 INTEL_G33_IDS(&intel_g33_info
),
625 INTEL_I965GM_IDS(&intel_i965gm_info
),
626 INTEL_GM45_IDS(&intel_gm45_info
),
627 INTEL_G45_IDS(&intel_g45_info
),
628 INTEL_PINEVIEW_IDS(&intel_pineview_info
),
629 INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info
),
630 INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info
),
631 INTEL_SNB_D_GT1_IDS(&intel_sandybridge_d_gt1_info
),
632 INTEL_SNB_D_GT2_IDS(&intel_sandybridge_d_gt2_info
),
633 INTEL_SNB_M_GT1_IDS(&intel_sandybridge_m_gt1_info
),
634 INTEL_SNB_M_GT2_IDS(&intel_sandybridge_m_gt2_info
),
635 INTEL_IVB_Q_IDS(&intel_ivybridge_q_info
), /* must be first IVB */
636 INTEL_IVB_M_GT1_IDS(&intel_ivybridge_m_gt1_info
),
637 INTEL_IVB_M_GT2_IDS(&intel_ivybridge_m_gt2_info
),
638 INTEL_IVB_D_GT1_IDS(&intel_ivybridge_d_gt1_info
),
639 INTEL_IVB_D_GT2_IDS(&intel_ivybridge_d_gt2_info
),
640 INTEL_HSW_GT1_IDS(&intel_haswell_gt1_info
),
641 INTEL_HSW_GT2_IDS(&intel_haswell_gt2_info
),
642 INTEL_HSW_GT3_IDS(&intel_haswell_gt3_info
),
643 INTEL_VLV_IDS(&intel_valleyview_info
),
644 INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info
),
645 INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info
),
646 INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info
),
647 INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info
),
648 INTEL_CHV_IDS(&intel_cherryview_info
),
649 INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info
),
650 INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info
),
651 INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info
),
652 INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info
),
653 INTEL_BXT_IDS(&intel_broxton_info
),
654 INTEL_GLK_IDS(&intel_geminilake_info
),
655 INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info
),
656 INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info
),
657 INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info
),
658 INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info
),
659 INTEL_AML_GT2_IDS(&intel_kabylake_gt2_info
),
660 INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info
),
661 INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info
),
662 INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info
),
663 INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info
),
664 INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info
),
665 INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info
),
666 INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info
),
667 INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info
),
668 INTEL_CNL_IDS(&intel_cannonlake_info
),
669 INTEL_ICL_11_IDS(&intel_icelake_11_info
),
672 MODULE_DEVICE_TABLE(pci
, pciidlist
);
674 static void i915_pci_remove(struct pci_dev
*pdev
)
676 struct drm_device
*dev
;
678 dev
= pci_get_drvdata(pdev
);
679 if (!dev
) /* driver load aborted, nothing to cleanup */
682 i915_driver_unload(dev
);
685 pci_set_drvdata(pdev
, NULL
);
688 static int i915_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
690 struct intel_device_info
*intel_info
=
691 (struct intel_device_info
*) ent
->driver_data
;
694 if (IS_ALPHA_SUPPORT(intel_info
) && !i915_modparams
.alpha_support
) {
695 DRM_INFO("The driver support for your hardware in this kernel version is alpha quality\n"
696 "See CONFIG_DRM_I915_ALPHA_SUPPORT or i915.alpha_support module parameter\n"
697 "to enable support in this kernel version, or check for kernel updates.\n");
701 /* Only bind to function 0 of the device. Early generations
702 * used function 1 as a placeholder for multi-head. This causes
703 * us confusion instead, especially on the systems where both
704 * functions have the same PCI-ID!
706 if (PCI_FUNC(pdev
->devfn
))
710 * apple-gmux is needed on dual GPU MacBook Pro
711 * to probe the panel if we're the inactive GPU.
713 if (vga_switcheroo_client_probe_defer(pdev
))
714 return -EPROBE_DEFER
;
716 err
= i915_driver_load(pdev
, ent
);
720 if (i915_inject_load_failure()) {
721 i915_pci_remove(pdev
);
725 err
= i915_live_selftests(pdev
);
727 i915_pci_remove(pdev
);
728 return err
> 0 ? -ENOTTY
: err
;
734 static struct pci_driver i915_pci_driver
= {
736 .id_table
= pciidlist
,
737 .probe
= i915_pci_probe
,
738 .remove
= i915_pci_remove
,
739 .driver
.pm
= &i915_pm_ops
,
742 static int __init
i915_init(void)
747 err
= i915_mock_selftests();
749 return err
> 0 ? 0 : err
;
752 * Enable KMS by default, unless explicitly overriden by
753 * either the i915.modeset prarameter or by the
754 * vga_text_mode_force boot option.
757 if (i915_modparams
.modeset
== 0)
760 if (vgacon_text_force() && i915_modparams
.modeset
== -1)
764 /* Silently fail loading to not upset userspace. */
765 DRM_DEBUG_DRIVER("KMS disabled.\n");
769 return pci_register_driver(&i915_pci_driver
);
772 static void __exit
i915_exit(void)
774 if (!i915_pci_driver
.driver
.owner
)
777 pci_unregister_driver(&i915_pci_driver
);
780 module_init(i915_init
);
781 module_exit(i915_exit
);
783 MODULE_AUTHOR("Tungsten Graphics, Inc.");
784 MODULE_AUTHOR("Intel Corporation");
786 MODULE_DESCRIPTION(DRIVER_DESC
);
787 MODULE_LICENSE("GPL and additional rights");