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 "xe_drv.h" 12 #include "xe_hw_fence.h" 13 #include "xe_pci.h" 14 #include "xe_sched_job.h" 15 16 struct xe_modparam xe_modparam = { 17 .enable_display = true, 18 .guc_log_level = 5, 19 .force_probe = CONFIG_DRM_XE_FORCE_PROBE, 20 .wedged_mode = 1, 21 /* the rest are 0 by default */ 22 }; 23 24 module_param_named_unsafe(force_execlist, xe_modparam.force_execlist, bool, 0444); 25 MODULE_PARM_DESC(force_execlist, "Force Execlist submission"); 26 27 module_param_named(enable_display, xe_modparam.enable_display, bool, 0444); 28 MODULE_PARM_DESC(enable_display, "Enable display"); 29 30 module_param_named(vram_bar_size, xe_modparam.force_vram_bar_size, uint, 0600); 31 MODULE_PARM_DESC(vram_bar_size, "Set the vram bar size(in MiB)"); 32 33 module_param_named(guc_log_level, xe_modparam.guc_log_level, int, 0600); 34 MODULE_PARM_DESC(guc_log_level, "GuC firmware logging level (0=disable, 1..5=enable with verbosity min..max)"); 35 36 module_param_named_unsafe(guc_firmware_path, xe_modparam.guc_firmware_path, charp, 0400); 37 MODULE_PARM_DESC(guc_firmware_path, 38 "GuC firmware path to use instead of the default one"); 39 40 module_param_named_unsafe(huc_firmware_path, xe_modparam.huc_firmware_path, charp, 0400); 41 MODULE_PARM_DESC(huc_firmware_path, 42 "HuC firmware path to use instead of the default one - empty string disables"); 43 44 module_param_named_unsafe(gsc_firmware_path, xe_modparam.gsc_firmware_path, charp, 0400); 45 MODULE_PARM_DESC(gsc_firmware_path, 46 "GSC firmware path to use instead of the default one - empty string disables"); 47 48 module_param_named_unsafe(force_probe, xe_modparam.force_probe, charp, 0400); 49 MODULE_PARM_DESC(force_probe, 50 "Force probe options for specified devices. See CONFIG_DRM_XE_FORCE_PROBE for details."); 51 52 #ifdef CONFIG_PCI_IOV 53 module_param_named(max_vfs, xe_modparam.max_vfs, uint, 0400); 54 MODULE_PARM_DESC(max_vfs, 55 "Limit number of Virtual Functions (VFs) that could be managed. " 56 "(0 = no VFs [default]; N = allow up to N VFs)"); 57 #endif 58 59 module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600); 60 MODULE_PARM_DESC(wedged_mode, 61 "Module's default policy for the wedged mode - 0=never, 1=upon-critical-errors[default], 2=upon-any-hang"); 62 63 struct init_funcs { 64 int (*init)(void); 65 void (*exit)(void); 66 }; 67 68 static const struct init_funcs init_funcs[] = { 69 { 70 .init = xe_hw_fence_module_init, 71 .exit = xe_hw_fence_module_exit, 72 }, 73 { 74 .init = xe_sched_job_module_init, 75 .exit = xe_sched_job_module_exit, 76 }, 77 { 78 .init = xe_register_pci_driver, 79 .exit = xe_unregister_pci_driver, 80 }, 81 }; 82 83 static int __init xe_init(void) 84 { 85 int err, i; 86 87 for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { 88 err = init_funcs[i].init(); 89 if (err) { 90 while (i--) 91 init_funcs[i].exit(); 92 return err; 93 } 94 } 95 96 return 0; 97 } 98 99 static void __exit xe_exit(void) 100 { 101 int i; 102 103 for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--) 104 init_funcs[i].exit(); 105 } 106 107 module_init(xe_init); 108 module_exit(xe_exit); 109 110 MODULE_AUTHOR("Intel Corporation"); 111 112 MODULE_DESCRIPTION(DRIVER_DESC); 113 MODULE_LICENSE("GPL and additional rights"); 114