xref: /linux/drivers/gpu/drm/xe/xe_module.c (revision c5288cda69ee2d8607f5026bd599a5cebf0ee783)
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 #ifdef CONFIG_PCI_IOV
52 module_param_named(max_vfs, xe_modparam.max_vfs, uint, 0400);
53 MODULE_PARM_DESC(max_vfs,
54 		 "Limit number of Virtual Functions (VFs) that could be managed. "
55 		 "(0 = no VFs [default]; N = allow up to N VFs)");
56 #endif
57 
58 struct init_funcs {
59 	int (*init)(void);
60 	void (*exit)(void);
61 };
62 
63 static const struct init_funcs init_funcs[] = {
64 	{
65 		.init = xe_hw_fence_module_init,
66 		.exit = xe_hw_fence_module_exit,
67 	},
68 	{
69 		.init = xe_sched_job_module_init,
70 		.exit = xe_sched_job_module_exit,
71 	},
72 	{
73 		.init = xe_register_pci_driver,
74 		.exit = xe_unregister_pci_driver,
75 	},
76 };
77 
78 static int __init xe_init(void)
79 {
80 	int err, i;
81 
82 	for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
83 		err = init_funcs[i].init();
84 		if (err) {
85 			while (i--)
86 				init_funcs[i].exit();
87 			return err;
88 		}
89 	}
90 
91 	return 0;
92 }
93 
94 static void __exit xe_exit(void)
95 {
96 	int i;
97 
98 	for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
99 		init_funcs[i].exit();
100 }
101 
102 module_init(xe_init);
103 module_exit(xe_exit);
104 
105 MODULE_AUTHOR("Intel Corporation");
106 
107 MODULE_DESCRIPTION(DRIVER_DESC);
108 MODULE_LICENSE("GPL and additional rights");
109