1
2
3
4
5
6
7#include <linux/console.h>
8
9#include "gem/i915_gem_context.h"
10#include "gem/i915_gem_object.h"
11#include "i915_active.h"
12#include "i915_buddy.h"
13#include "i915_params.h"
14#include "i915_pci.h"
15#include "i915_perf.h"
16#include "i915_request.h"
17#include "i915_scheduler.h"
18#include "i915_selftest.h"
19#include "i915_vma.h"
20
21static int i915_check_nomodeset(void)
22{
23 bool use_kms = true;
24
25
26
27
28
29
30
31 if (i915_modparams.modeset == 0)
32 use_kms = false;
33
34 if (vgacon_text_force() && i915_modparams.modeset == -1)
35 use_kms = false;
36
37 if (!use_kms) {
38
39 DRM_DEBUG_DRIVER("KMS disabled.\n");
40 return 1;
41 }
42
43 return 0;
44}
45
46static const struct {
47 int (*init)(void);
48 void (*exit)(void);
49} init_funcs[] = {
50 { .init = i915_check_nomodeset },
51 { .init = i915_active_module_init,
52 .exit = i915_active_module_exit },
53 { .init = i915_buddy_module_init,
54 .exit = i915_buddy_module_exit },
55 { .init = i915_context_module_init,
56 .exit = i915_context_module_exit },
57 { .init = i915_gem_context_module_init,
58 .exit = i915_gem_context_module_exit },
59 { .init = i915_objects_module_init,
60 .exit = i915_objects_module_exit },
61 { .init = i915_request_module_init,
62 .exit = i915_request_module_exit },
63 { .init = i915_scheduler_module_init,
64 .exit = i915_scheduler_module_exit },
65 { .init = i915_vma_module_init,
66 .exit = i915_vma_module_exit },
67 { .init = i915_mock_selftests },
68 { .init = i915_pmu_init,
69 .exit = i915_pmu_exit },
70 { .init = i915_register_pci_driver,
71 .exit = i915_unregister_pci_driver },
72 { .init = i915_perf_sysctl_register,
73 .exit = i915_perf_sysctl_unregister },
74};
75static int init_progress;
76
77static int __init i915_init(void)
78{
79 int err, i;
80
81 for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
82 err = init_funcs[i].init();
83 if (err < 0) {
84 while (i--) {
85 if (init_funcs[i].exit)
86 init_funcs[i].exit();
87 }
88 return err;
89 } else if (err > 0) {
90
91
92
93
94
95
96 WARN_ON(init_funcs[i].exit);
97 break;
98 }
99 }
100
101 init_progress = i;
102
103 return 0;
104}
105
106static void __exit i915_exit(void)
107{
108 int i;
109
110 for (i = init_progress - 1; i >= 0; i--) {
111 GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
112 if (init_funcs[i].exit)
113 init_funcs[i].exit();
114 }
115}
116
117module_init(i915_init);
118module_exit(i915_exit);
119
120MODULE_AUTHOR("Tungsten Graphics, Inc.");
121MODULE_AUTHOR("Intel Corporation");
122
123MODULE_DESCRIPTION(DRIVER_DESC);
124MODULE_LICENSE("GPL and additional rights");
125