xref: /linux/drivers/gpu/drm/xe/xe_module.c (revision 4b660dbd9ee2059850fd30e0df420ca7a38a1856)
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 	/* the rest are 0 by default */
21 };
22 
23 module_param_named_unsafe(force_execlist, xe_modparam.force_execlist, bool, 0444);
24 MODULE_PARM_DESC(force_execlist, "Force Execlist submission");
25 
26 module_param_named(enable_display, xe_modparam.enable_display, bool, 0444);
27 MODULE_PARM_DESC(enable_display, "Enable display");
28 
29 module_param_named(vram_bar_size, xe_modparam.force_vram_bar_size, uint, 0600);
30 MODULE_PARM_DESC(vram_bar_size, "Set the vram bar size(in MiB)");
31 
32 module_param_named(guc_log_level, xe_modparam.guc_log_level, int, 0600);
33 MODULE_PARM_DESC(guc_log_level, "GuC firmware logging level (0=disable, 1..5=enable with verbosity min..max)");
34 
35 module_param_named_unsafe(guc_firmware_path, xe_modparam.guc_firmware_path, charp, 0400);
36 MODULE_PARM_DESC(guc_firmware_path,
37 		 "GuC firmware path to use instead of the default one");
38 
39 module_param_named_unsafe(huc_firmware_path, xe_modparam.huc_firmware_path, charp, 0400);
40 MODULE_PARM_DESC(huc_firmware_path,
41 		 "HuC firmware path to use instead of the default one - empty string disables");
42 
43 module_param_named_unsafe(gsc_firmware_path, xe_modparam.gsc_firmware_path, charp, 0400);
44 MODULE_PARM_DESC(gsc_firmware_path,
45 		 "GSC firmware path to use instead of the default one - empty string disables");
46 
47 module_param_named_unsafe(force_probe, xe_modparam.force_probe, charp, 0400);
48 MODULE_PARM_DESC(force_probe,
49 		 "Force probe options for specified devices. See CONFIG_DRM_XE_FORCE_PROBE for details.");
50 
51 struct init_funcs {
52 	int (*init)(void);
53 	void (*exit)(void);
54 };
55 
56 static const struct init_funcs init_funcs[] = {
57 	{
58 		.init = xe_hw_fence_module_init,
59 		.exit = xe_hw_fence_module_exit,
60 	},
61 	{
62 		.init = xe_sched_job_module_init,
63 		.exit = xe_sched_job_module_exit,
64 	},
65 	{
66 		.init = xe_register_pci_driver,
67 		.exit = xe_unregister_pci_driver,
68 	},
69 };
70 
71 static int __init xe_init(void)
72 {
73 	int err, i;
74 
75 	for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
76 		err = init_funcs[i].init();
77 		if (err) {
78 			while (i--)
79 				init_funcs[i].exit();
80 			return err;
81 		}
82 	}
83 
84 	return 0;
85 }
86 
87 static void __exit xe_exit(void)
88 {
89 	int i;
90 
91 	for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
92 		init_funcs[i].exit();
93 }
94 
95 module_init(xe_init);
96 module_exit(xe_exit);
97 
98 MODULE_AUTHOR("Intel Corporation");
99 
100 MODULE_DESCRIPTION(DRIVER_DESC);
101 MODULE_LICENSE("GPL and additional rights");
102