FILE
i915_module.c
File preview with syntax highlighting.
linux-6.19.14/drivers/gpu/drm/i915/i915_module.c
1/* 2 * SPDX-License-Identifier: MIT 3 * 4 * Copyright © 2021 Intel Corporation 5 */ 6 7#include <drm/drm_drv.h> 8#include <drm/drm_print.h> 9 10#include "gem/i915_gem_context.h" 11#include "gem/i915_gem_object.h" 12#include "i915_active.h" 13#include "i915_driver.h" 14#include "i915_params.h" 15#include "i915_pci.h" 16#include "i915_perf.h" 17#include "i915_request.h" 18#include "i915_scheduler.h" 19#include "i915_selftest.h" 20#include "i915_vma.h" 21#include "i915_vma_resource.h" 22 23static int i915_check_nomodeset(void) 24{ 25 bool use_kms = true; 26 27 /* 28 * Enable KMS by default, unless explicitly overridden by 29 * either the i915.modeset parameter or by the 30 * nomodeset boot option. 31 */ 32 33 if (i915_modparams.modeset == 0) 34 pr_warn("i915.modeset=0 is deprecated. Please use the 'nomodeset' kernel parameter instead.\n"); 35 else if (i915_modparams.modeset != -1) 36 pr_warn("i915.modeset=%d is deprecated. Please remove it and the 'nomodeset' kernel parameter instead.\n", 37 i915_modparams.modeset); 38 39 if (i915_modparams.modeset == 0) 40 use_kms = false; 41 42 if (drm_firmware_drivers_only() && i915_modparams.modeset == -1) 43 use_kms = false; 44 45 if (!use_kms) { 46 DRM_DEBUG_DRIVER("KMS disabled.\n"); 47 return -ENODEV; 48 } 49 50 return 0; 51} 52 53static const struct { 54 int (*init)(void); 55 void (*exit)(void); 56} init_funcs[] = { 57 { .init = i915_check_nomodeset }, 58 { .init = i915_active_module_init, 59 .exit = i915_active_module_exit }, 60 { .init = i915_context_module_init, 61 .exit = i915_context_module_exit }, 62 { .init = i915_gem_context_module_init, 63 .exit = i915_gem_context_module_exit }, 64 { .init = i915_objects_module_init, 65 .exit = i915_objects_module_exit }, 66 { .init = i915_request_module_init, 67 .exit = i915_request_module_exit }, 68 { .init = i915_scheduler_module_init, 69 .exit = i915_scheduler_module_exit }, 70 { .init = i915_vma_module_init, 71 .exit = i915_vma_module_exit }, 72 { .init = i915_vma_resource_module_init, 73 .exit = i915_vma_resource_module_exit }, 74 { .init = i915_mock_selftests }, 75 { .init = i915_pci_register_driver, 76 .exit = i915_pci_unregister_driver }, 77 { .init = i915_perf_sysctl_register, 78 .exit = i915_perf_sysctl_unregister }, 79}; 80static int init_progress; 81 82static int __init i915_init(void) 83{ 84 int err, i; 85 86 for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { 87 err = init_funcs[i].init(); 88 if (err < 0) { 89 while (i--) { 90 if (init_funcs[i].exit) 91 init_funcs[i].exit(); 92 } 93 return err; 94 } else if (err > 0) { 95 /* 96 * Early-exit success is reserved for things which 97 * don't have an exit() function because we have no 98 * idea how far they got or how to partially tear 99 * them down. 100 */ 101 WARN_ON(init_funcs[i].exit); 102 break; 103 } 104 } 105 106 init_progress = i; 107 108 return 0; 109} 110 111static void __exit i915_exit(void) 112{ 113 int i; 114 115 for (i = init_progress - 1; i >= 0; i--) { 116 GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs)); 117 if (init_funcs[i].exit) 118 init_funcs[i].exit(); 119 } 120} 121 122module_init(i915_init); 123module_exit(i915_exit); 124 125MODULE_AUTHOR("Tungsten Graphics, Inc."); 126MODULE_AUTHOR("Intel Corporation"); 127 128MODULE_DESCRIPTION(DRIVER_DESC); 129MODULE_LICENSE("GPL and additional rights");
~/
Read-only file preview.