Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * SPDX-License-Identifier: MIT
0003  *
0004  * Copyright © 2021 Intel Corporation
0005  */
0006 
0007 #include <drm/drm_drv.h>
0008 
0009 #include "gem/i915_gem_context.h"
0010 #include "gem/i915_gem_object.h"
0011 #include "i915_active.h"
0012 #include "i915_driver.h"
0013 #include "i915_params.h"
0014 #include "i915_pci.h"
0015 #include "i915_perf.h"
0016 #include "i915_request.h"
0017 #include "i915_scheduler.h"
0018 #include "i915_selftest.h"
0019 #include "i915_vma.h"
0020 #include "i915_vma_resource.h"
0021 
0022 static int i915_check_nomodeset(void)
0023 {
0024     bool use_kms = true;
0025 
0026     /*
0027      * Enable KMS by default, unless explicitly overriden by
0028      * either the i915.modeset parameter or by the
0029      * nomodeset boot option.
0030      */
0031 
0032     if (i915_modparams.modeset == 0)
0033         use_kms = false;
0034 
0035     if (drm_firmware_drivers_only() && i915_modparams.modeset == -1)
0036         use_kms = false;
0037 
0038     if (!use_kms) {
0039         /* Silently fail loading to not upset userspace. */
0040         DRM_DEBUG_DRIVER("KMS disabled.\n");
0041         return 1;
0042     }
0043 
0044     return 0;
0045 }
0046 
0047 static const struct {
0048    int (*init)(void);
0049    void (*exit)(void);
0050 } init_funcs[] = {
0051     { .init = i915_check_nomodeset },
0052     { .init = i915_active_module_init,
0053       .exit = i915_active_module_exit },
0054     { .init = i915_context_module_init,
0055       .exit = i915_context_module_exit },
0056     { .init = i915_gem_context_module_init,
0057       .exit = i915_gem_context_module_exit },
0058     { .init = i915_objects_module_init,
0059       .exit = i915_objects_module_exit },
0060     { .init = i915_request_module_init,
0061       .exit = i915_request_module_exit },
0062     { .init = i915_scheduler_module_init,
0063       .exit = i915_scheduler_module_exit },
0064     { .init = i915_vma_module_init,
0065       .exit = i915_vma_module_exit },
0066     { .init = i915_vma_resource_module_init,
0067       .exit = i915_vma_resource_module_exit },
0068     { .init = i915_mock_selftests },
0069     { .init = i915_pmu_init,
0070       .exit = i915_pmu_exit },
0071     { .init = i915_pci_register_driver,
0072       .exit = i915_pci_unregister_driver },
0073     { .init = i915_perf_sysctl_register,
0074       .exit = i915_perf_sysctl_unregister },
0075 };
0076 static int init_progress;
0077 
0078 static int __init i915_init(void)
0079 {
0080     int err, i;
0081 
0082     for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
0083         err = init_funcs[i].init();
0084         if (err < 0) {
0085             while (i--) {
0086                 if (init_funcs[i].exit)
0087                     init_funcs[i].exit();
0088             }
0089             return err;
0090         } else if (err > 0) {
0091             /*
0092              * Early-exit success is reserved for things which
0093              * don't have an exit() function because we have no
0094              * idea how far they got or how to partially tear
0095              * them down.
0096              */
0097             WARN_ON(init_funcs[i].exit);
0098             break;
0099         }
0100     }
0101 
0102     init_progress = i;
0103 
0104     return 0;
0105 }
0106 
0107 static void __exit i915_exit(void)
0108 {
0109     int i;
0110 
0111     for (i = init_progress - 1; i >= 0; i--) {
0112         GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs));
0113         if (init_funcs[i].exit)
0114             init_funcs[i].exit();
0115     }
0116 }
0117 
0118 module_init(i915_init);
0119 module_exit(i915_exit);
0120 
0121 MODULE_AUTHOR("Tungsten Graphics, Inc.");
0122 MODULE_AUTHOR("Intel Corporation");
0123 
0124 MODULE_DESCRIPTION(DRIVER_DESC);
0125 MODULE_LICENSE("GPL and additional rights");