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 }
41 #define GEN_CHV_PIPEOFFSETS \
42 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
43 CHV_PIPE_C_OFFSET }, \
44 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
45 CHV_TRANSCODER_C_OFFSET }
47 #define CURSOR_OFFSETS \
48 .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
50 #define IVB_CURSOR_OFFSETS \
51 .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
54 .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
56 .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
58 .color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
60 /* Keep in gen based order, and chronological order within a gen */
62 #define GEN_DEFAULT_PAGE_SIZES \
63 .page_sizes = I915_GTT_PAGE_SIZE_4K
65 #define GEN2_FEATURES \
68 .has_overlay = 1, .overlay_needs_physical = 1, \
69 .has_gmch_display = 1, \
70 .hws_needs_physical = 1, \
71 .unfenced_needs_alignment = 1, \
72 .ring_mask = RENDER_RING, \
74 .has_coherent_ggtt = false, \
75 GEN_DEFAULT_PIPEOFFSETS, \
76 GEN_DEFAULT_PAGE_SIZES, \
79 static const struct intel_device_info intel_i830_info = {
82 .is_mobile = 1, .cursor_needs_physical = 1,
83 .num_pipes = 2, /* legal, last one wins */
86 static const struct intel_device_info intel_i845g_info = {
88 PLATFORM(INTEL_I845G),
91 static const struct intel_device_info intel_i85x_info = {
95 .num_pipes = 2, /* legal, last one wins */
96 .cursor_needs_physical = 1,
100 static const struct intel_device_info intel_i865g_info = {
102 PLATFORM(INTEL_I865G),
105 #define GEN3_FEATURES \
108 .has_gmch_display = 1, \
109 .ring_mask = RENDER_RING, \
111 .has_coherent_ggtt = true, \
112 GEN_DEFAULT_PIPEOFFSETS, \
113 GEN_DEFAULT_PAGE_SIZES, \
116 static const struct intel_device_info intel_i915g_info = {
118 PLATFORM(INTEL_I915G),
119 .has_coherent_ggtt = false,
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 .has_coherent_ggtt = true, \
182 GEN_DEFAULT_PIPEOFFSETS, \
183 GEN_DEFAULT_PAGE_SIZES, \
186 static const struct intel_device_info intel_i965g_info = {
188 PLATFORM(INTEL_I965G),
190 .hws_needs_physical = 1,
194 static const struct intel_device_info intel_i965gm_info = {
196 PLATFORM(INTEL_I965GM),
197 .is_mobile = 1, .has_fbc = 1,
200 .hws_needs_physical = 1,
204 static const struct intel_device_info intel_g45_info = {
207 .ring_mask = RENDER_RING | BSD_RING,
210 static const struct intel_device_info intel_gm45_info = {
212 PLATFORM(INTEL_GM45),
213 .is_mobile = 1, .has_fbc = 1,
215 .ring_mask = RENDER_RING | BSD_RING,
218 #define GEN5_FEATURES \
222 .ring_mask = RENDER_RING | BSD_RING, \
224 .has_coherent_ggtt = true, \
225 /* ilk does support rc6, but we do not implement [power] contexts */ \
227 GEN_DEFAULT_PIPEOFFSETS, \
228 GEN_DEFAULT_PAGE_SIZES, \
231 static const struct intel_device_info intel_ironlake_d_info = {
233 PLATFORM(INTEL_IRONLAKE),
236 static const struct intel_device_info intel_ironlake_m_info = {
238 PLATFORM(INTEL_IRONLAKE),
239 .is_mobile = 1, .has_fbc = 1,
242 #define GEN6_FEATURES \
247 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
248 .has_coherent_ggtt = true, \
252 .ppgtt = INTEL_PPGTT_ALIASING, \
253 GEN_DEFAULT_PIPEOFFSETS, \
254 GEN_DEFAULT_PAGE_SIZES, \
257 #define SNB_D_PLATFORM \
259 PLATFORM(INTEL_SANDYBRIDGE)
261 static const struct intel_device_info intel_sandybridge_d_gt1_info = {
266 static const struct intel_device_info intel_sandybridge_d_gt2_info = {
271 #define SNB_M_PLATFORM \
273 PLATFORM(INTEL_SANDYBRIDGE), \
277 static const struct intel_device_info intel_sandybridge_m_gt1_info = {
282 static const struct intel_device_info intel_sandybridge_m_gt2_info = {
287 #define GEN7_FEATURES \
292 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
293 .has_coherent_ggtt = true, \
297 .ppgtt = INTEL_PPGTT_FULL, \
298 GEN_DEFAULT_PIPEOFFSETS, \
299 GEN_DEFAULT_PAGE_SIZES, \
302 #define IVB_D_PLATFORM \
304 PLATFORM(INTEL_IVYBRIDGE), \
307 static const struct intel_device_info intel_ivybridge_d_gt1_info = {
312 static const struct intel_device_info intel_ivybridge_d_gt2_info = {
317 #define IVB_M_PLATFORM \
319 PLATFORM(INTEL_IVYBRIDGE), \
323 static const struct intel_device_info intel_ivybridge_m_gt1_info = {
328 static const struct intel_device_info intel_ivybridge_m_gt2_info = {
333 static const struct intel_device_info intel_ivybridge_q_info = {
335 PLATFORM(INTEL_IVYBRIDGE),
337 .num_pipes = 0, /* legal, last one wins */
341 static const struct intel_device_info intel_valleyview_info = {
342 PLATFORM(INTEL_VALLEYVIEW),
348 .has_gmch_display = 1,
350 .ppgtt = INTEL_PPGTT_FULL,
352 .has_coherent_ggtt = false,
353 .ring_mask = RENDER_RING | BSD_RING | BLT_RING,
354 .display_mmio_offset = VLV_DISPLAY_BASE,
355 GEN_DEFAULT_PAGE_SIZES,
356 GEN_DEFAULT_PIPEOFFSETS,
360 #define G75_FEATURES \
362 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
367 .has_rc6p = 0 /* RC6p removed-by HSW */, \
370 #define HSW_PLATFORM \
372 PLATFORM(INTEL_HASWELL), \
375 static const struct intel_device_info intel_haswell_gt1_info = {
380 static const struct intel_device_info intel_haswell_gt2_info = {
385 static const struct intel_device_info intel_haswell_gt3_info = {
390 #define GEN8_FEATURES \
394 .page_sizes = I915_GTT_PAGE_SIZE_4K | \
395 I915_GTT_PAGE_SIZE_2M, \
396 .has_logical_ring_contexts = 1, \
397 .ppgtt = INTEL_PPGTT_FULL_4LVL, \
398 .has_64bit_reloc = 1, \
399 .has_reset_engine = 1
401 #define BDW_PLATFORM \
403 PLATFORM(INTEL_BROADWELL)
405 static const struct intel_device_info intel_broadwell_gt1_info = {
410 static const struct intel_device_info intel_broadwell_gt2_info = {
415 static const struct intel_device_info intel_broadwell_rsvd_info = {
418 /* According to the device ID those devices are GT3, they were
419 * previously treated as not GT3, keep it like that.
423 static const struct intel_device_info intel_broadwell_gt3_info = {
426 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
429 static const struct intel_device_info intel_cherryview_info = {
430 PLATFORM(INTEL_CHERRYVIEW),
435 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
436 .has_64bit_reloc = 1,
439 .has_logical_ring_contexts = 1,
440 .has_gmch_display = 1,
441 .ppgtt = INTEL_PPGTT_FULL,
442 .has_reset_engine = 1,
444 .has_coherent_ggtt = false,
445 .display_mmio_offset = VLV_DISPLAY_BASE,
446 GEN_DEFAULT_PAGE_SIZES,
452 #define GEN9_DEFAULT_PAGE_SIZES \
453 .page_sizes = I915_GTT_PAGE_SIZE_4K | \
454 I915_GTT_PAGE_SIZE_64K | \
455 I915_GTT_PAGE_SIZE_2M
457 #define GEN9_FEATURES \
460 GEN9_DEFAULT_PAGE_SIZES, \
461 .has_logical_ring_preemption = 1, \
467 #define SKL_PLATFORM \
469 /* Display WA #0477 WaDisableIPC: skl */ \
471 PLATFORM(INTEL_SKYLAKE)
473 static const struct intel_device_info intel_skylake_gt1_info = {
478 static const struct intel_device_info intel_skylake_gt2_info = {
483 #define SKL_GT3_PLUS_PLATFORM \
485 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING
488 static const struct intel_device_info intel_skylake_gt3_info = {
489 SKL_GT3_PLUS_PLATFORM,
493 static const struct intel_device_info intel_skylake_gt4_info = {
494 SKL_GT3_PLUS_PLATFORM,
498 #define GEN9_LP_FEATURES \
502 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
504 .has_64bit_reloc = 1, \
509 .has_runtime_pm = 1, \
510 .has_pooled_eu = 0, \
514 .has_logical_ring_contexts = 1, \
515 .has_logical_ring_preemption = 1, \
517 .ppgtt = INTEL_PPGTT_FULL_4LVL, \
518 .has_reset_engine = 1, \
520 .has_coherent_ggtt = false, \
522 GEN9_DEFAULT_PAGE_SIZES, \
523 GEN_DEFAULT_PIPEOFFSETS, \
524 IVB_CURSOR_OFFSETS, \
527 static const struct intel_device_info intel_broxton_info = {
529 PLATFORM(INTEL_BROXTON),
533 static const struct intel_device_info intel_geminilake_info = {
535 PLATFORM(INTEL_GEMINILAKE),
540 #define KBL_PLATFORM \
542 PLATFORM(INTEL_KABYLAKE)
544 static const struct intel_device_info intel_kabylake_gt1_info = {
549 static const struct intel_device_info intel_kabylake_gt2_info = {
554 static const struct intel_device_info intel_kabylake_gt3_info = {
557 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
560 #define CFL_PLATFORM \
562 PLATFORM(INTEL_COFFEELAKE)
564 static const struct intel_device_info intel_coffeelake_gt1_info = {
569 static const struct intel_device_info intel_coffeelake_gt2_info = {
574 static const struct intel_device_info intel_coffeelake_gt3_info = {
577 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
580 #define GEN10_FEATURES \
584 .has_coherent_ggtt = false, \
587 static const struct intel_device_info intel_cannonlake_info = {
589 PLATFORM(INTEL_CANNONLAKE),
593 #define GEN11_FEATURES \
595 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
596 PIPE_C_OFFSET, PIPE_EDP_OFFSET, \
597 PIPE_DSI0_OFFSET, PIPE_DSI1_OFFSET }, \
598 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
599 TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET, \
600 TRANSCODER_DSI0_OFFSET, TRANSCODER_DSI1_OFFSET}, \
603 .has_logical_ring_elsq = 1
605 static const struct intel_device_info intel_icelake_11_info = {
607 PLATFORM(INTEL_ICELAKE),
608 .is_alpha_support = 1,
609 .ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING,
616 * Make sure any device matches here are from most specific to most
617 * general. For example, since the Quanta match is based on the subsystem
618 * and subvendor IDs, we need it to come before the more general IVB
619 * PCI ID matches, otherwise we'll use the wrong info struct above.
621 static const struct pci_device_id pciidlist[] = {
622 INTEL_I830_IDS(&intel_i830_info),
623 INTEL_I845G_IDS(&intel_i845g_info),
624 INTEL_I85X_IDS(&intel_i85x_info),
625 INTEL_I865G_IDS(&intel_i865g_info),
626 INTEL_I915G_IDS(&intel_i915g_info),
627 INTEL_I915GM_IDS(&intel_i915gm_info),
628 INTEL_I945G_IDS(&intel_i945g_info),
629 INTEL_I945GM_IDS(&intel_i945gm_info),
630 INTEL_I965G_IDS(&intel_i965g_info),
631 INTEL_G33_IDS(&intel_g33_info),
632 INTEL_I965GM_IDS(&intel_i965gm_info),
633 INTEL_GM45_IDS(&intel_gm45_info),
634 INTEL_G45_IDS(&intel_g45_info),
635 INTEL_PINEVIEW_IDS(&intel_pineview_info),
636 INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
637 INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
638 INTEL_SNB_D_GT1_IDS(&intel_sandybridge_d_gt1_info),
639 INTEL_SNB_D_GT2_IDS(&intel_sandybridge_d_gt2_info),
640 INTEL_SNB_M_GT1_IDS(&intel_sandybridge_m_gt1_info),
641 INTEL_SNB_M_GT2_IDS(&intel_sandybridge_m_gt2_info),
642 INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
643 INTEL_IVB_M_GT1_IDS(&intel_ivybridge_m_gt1_info),
644 INTEL_IVB_M_GT2_IDS(&intel_ivybridge_m_gt2_info),
645 INTEL_IVB_D_GT1_IDS(&intel_ivybridge_d_gt1_info),
646 INTEL_IVB_D_GT2_IDS(&intel_ivybridge_d_gt2_info),
647 INTEL_HSW_GT1_IDS(&intel_haswell_gt1_info),
648 INTEL_HSW_GT2_IDS(&intel_haswell_gt2_info),
649 INTEL_HSW_GT3_IDS(&intel_haswell_gt3_info),
650 INTEL_VLV_IDS(&intel_valleyview_info),
651 INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
652 INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
653 INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
654 INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
655 INTEL_CHV_IDS(&intel_cherryview_info),
656 INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
657 INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
658 INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
659 INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
660 INTEL_BXT_IDS(&intel_broxton_info),
661 INTEL_GLK_IDS(&intel_geminilake_info),
662 INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
663 INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
664 INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
665 INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
666 INTEL_AML_KBL_GT2_IDS(&intel_kabylake_gt2_info),
667 INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
668 INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
669 INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
670 INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
671 INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
672 INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
673 INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
674 INTEL_AML_CFL_GT2_IDS(&intel_coffeelake_gt2_info),
675 INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
676 INTEL_CNL_IDS(&intel_cannonlake_info),
677 INTEL_ICL_11_IDS(&intel_icelake_11_info),
680 MODULE_DEVICE_TABLE(pci, pciidlist);
682 static void i915_pci_remove(struct pci_dev *pdev)
684 struct drm_device *dev;
686 dev = pci_get_drvdata(pdev);
687 if (!dev) /* driver load aborted, nothing to cleanup */
690 i915_driver_unload(dev);
693 pci_set_drvdata(pdev, NULL);
696 static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
698 struct intel_device_info *intel_info =
699 (struct intel_device_info *) ent->driver_data;
702 if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
703 DRM_INFO("The driver support for your hardware in this kernel version is alpha quality\n"
704 "See CONFIG_DRM_I915_ALPHA_SUPPORT or i915.alpha_support module parameter\n"
705 "to enable support in this kernel version, or check for kernel updates.\n");
709 /* Only bind to function 0 of the device. Early generations
710 * used function 1 as a placeholder for multi-head. This causes
711 * us confusion instead, especially on the systems where both
712 * functions have the same PCI-ID!
714 if (PCI_FUNC(pdev->devfn))
718 * apple-gmux is needed on dual GPU MacBook Pro
719 * to probe the panel if we're the inactive GPU.
721 if (vga_switcheroo_client_probe_defer(pdev))
722 return -EPROBE_DEFER;
724 err = i915_driver_load(pdev, ent);
728 if (i915_inject_load_failure()) {
729 i915_pci_remove(pdev);
733 err = i915_live_selftests(pdev);
735 i915_pci_remove(pdev);
736 return err > 0 ? -ENOTTY : err;
742 static struct pci_driver i915_pci_driver = {
744 .id_table = pciidlist,
745 .probe = i915_pci_probe,
746 .remove = i915_pci_remove,
747 .driver.pm = &i915_pm_ops,
750 static int __init i915_init(void)
755 err = i915_mock_selftests();
757 return err > 0 ? 0 : err;
760 * Enable KMS by default, unless explicitly overriden by
761 * either the i915.modeset prarameter or by the
762 * vga_text_mode_force boot option.
765 if (i915_modparams.modeset == 0)
768 if (vgacon_text_force() && i915_modparams.modeset == -1)
772 /* Silently fail loading to not upset userspace. */
773 DRM_DEBUG_DRIVER("KMS disabled.\n");
777 return pci_register_driver(&i915_pci_driver);
780 static void __exit i915_exit(void)
782 if (!i915_pci_driver.driver.owner)
785 pci_unregister_driver(&i915_pci_driver);
788 module_init(i915_init);
789 module_exit(i915_exit);
791 MODULE_AUTHOR("Tungsten Graphics, Inc.");
792 MODULE_AUTHOR("Intel Corporation");
794 MODULE_DESCRIPTION(DRIVER_DESC);
795 MODULE_LICENSE("GPL and additional rights");