Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.13-rc4 160 lines 3.9 kB view raw
1// SPDX-License-Identifier: MIT 2/* 3 * Copyright © 2021 Intel Corporation 4 */ 5 6#include "xe_module.h" 7 8#include <linux/init.h> 9#include <linux/module.h> 10 11#include <drm/drm_module.h> 12 13#include "xe_drv.h" 14#include "xe_hw_fence.h" 15#include "xe_pci.h" 16#include "xe_pm.h" 17#include "xe_observation.h" 18#include "xe_sched_job.h" 19 20struct xe_modparam xe_modparam = { 21 .probe_display = true, 22 .guc_log_level = 5, 23 .force_probe = CONFIG_DRM_XE_FORCE_PROBE, 24 .wedged_mode = 1, 25 /* the rest are 0 by default */ 26}; 27 28module_param_named_unsafe(force_execlist, xe_modparam.force_execlist, bool, 0444); 29MODULE_PARM_DESC(force_execlist, "Force Execlist submission"); 30 31module_param_named(probe_display, xe_modparam.probe_display, bool, 0444); 32MODULE_PARM_DESC(probe_display, "Probe display HW, otherwise it's left untouched (default: true)"); 33 34module_param_named(vram_bar_size, xe_modparam.force_vram_bar_size, uint, 0600); 35MODULE_PARM_DESC(vram_bar_size, "Set the vram bar size(in MiB)"); 36 37module_param_named(guc_log_level, xe_modparam.guc_log_level, int, 0600); 38MODULE_PARM_DESC(guc_log_level, "GuC firmware logging level (0=disable, 1..5=enable with verbosity min..max)"); 39 40module_param_named_unsafe(guc_firmware_path, xe_modparam.guc_firmware_path, charp, 0400); 41MODULE_PARM_DESC(guc_firmware_path, 42 "GuC firmware path to use instead of the default one"); 43 44module_param_named_unsafe(huc_firmware_path, xe_modparam.huc_firmware_path, charp, 0400); 45MODULE_PARM_DESC(huc_firmware_path, 46 "HuC firmware path to use instead of the default one - empty string disables"); 47 48module_param_named_unsafe(gsc_firmware_path, xe_modparam.gsc_firmware_path, charp, 0400); 49MODULE_PARM_DESC(gsc_firmware_path, 50 "GSC firmware path to use instead of the default one - empty string disables"); 51 52module_param_named_unsafe(force_probe, xe_modparam.force_probe, charp, 0400); 53MODULE_PARM_DESC(force_probe, 54 "Force probe options for specified devices. See CONFIG_DRM_XE_FORCE_PROBE for details."); 55 56#ifdef CONFIG_PCI_IOV 57module_param_named(max_vfs, xe_modparam.max_vfs, uint, 0400); 58MODULE_PARM_DESC(max_vfs, 59 "Limit number of Virtual Functions (VFs) that could be managed. " 60 "(0 = no VFs [default]; N = allow up to N VFs)"); 61#endif 62 63module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600); 64MODULE_PARM_DESC(wedged_mode, 65 "Module's default policy for the wedged mode - 0=never, 1=upon-critical-errors[default], 2=upon-any-hang"); 66 67static int xe_check_nomodeset(void) 68{ 69 if (drm_firmware_drivers_only()) 70 return -ENODEV; 71 72 return 0; 73} 74 75struct init_funcs { 76 int (*init)(void); 77 void (*exit)(void); 78}; 79 80static void xe_dummy_exit(void) 81{ 82} 83 84static const struct init_funcs init_funcs[] = { 85 { 86 .init = xe_check_nomodeset, 87 }, 88 { 89 .init = xe_hw_fence_module_init, 90 .exit = xe_hw_fence_module_exit, 91 }, 92 { 93 .init = xe_sched_job_module_init, 94 .exit = xe_sched_job_module_exit, 95 }, 96 { 97 .init = xe_register_pci_driver, 98 .exit = xe_unregister_pci_driver, 99 }, 100 { 101 .init = xe_observation_sysctl_register, 102 .exit = xe_observation_sysctl_unregister, 103 }, 104 { 105 .init = xe_pm_module_init, 106 .exit = xe_dummy_exit, 107 }, 108}; 109 110static int __init xe_call_init_func(unsigned int i) 111{ 112 if (WARN_ON(i >= ARRAY_SIZE(init_funcs))) 113 return 0; 114 if (!init_funcs[i].init) 115 return 0; 116 117 return init_funcs[i].init(); 118} 119 120static void xe_call_exit_func(unsigned int i) 121{ 122 if (WARN_ON(i >= ARRAY_SIZE(init_funcs))) 123 return; 124 if (!init_funcs[i].exit) 125 return; 126 127 init_funcs[i].exit(); 128} 129 130static int __init xe_init(void) 131{ 132 int err, i; 133 134 for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { 135 err = xe_call_init_func(i); 136 if (err) { 137 while (i--) 138 xe_call_exit_func(i); 139 return err; 140 } 141 } 142 143 return 0; 144} 145 146static void __exit xe_exit(void) 147{ 148 int i; 149 150 for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--) 151 xe_call_exit_func(i); 152} 153 154module_init(xe_init); 155module_exit(xe_exit); 156 157MODULE_AUTHOR("Intel Corporation"); 158 159MODULE_DESCRIPTION(DRIVER_DESC); 160MODULE_LICENSE("GPL and additional rights");