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