File Index
Files and directories
Sign in
FILE

xe_module.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/xe/xe_module.c C
  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_configfs.h"
 15#include "xe_hw_fence.h"
 16#include "xe_pci.h"
 17#include "xe_pm.h"
 18#include "xe_observation.h"
 19#include "xe_sched_job.h"
 20
 21#if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
 22#define DEFAULT_GUC_LOG_LEVEL		3
 23#else
 24#define DEFAULT_GUC_LOG_LEVEL		1
 25#endif
 26
 27#define DEFAULT_PROBE_DISPLAY		true
 28#define DEFAULT_VRAM_BAR_SIZE		0
 29#define DEFAULT_FORCE_PROBE		CONFIG_DRM_XE_FORCE_PROBE
 30#define DEFAULT_MAX_VFS			~0
 31#define DEFAULT_MAX_VFS_STR		"unlimited"
 32#define DEFAULT_WEDGED_MODE		1
 33#define DEFAULT_SVM_NOTIFIER_SIZE	512
 34
 35struct xe_modparam xe_modparam = {
 36	.probe_display =	DEFAULT_PROBE_DISPLAY,
 37	.guc_log_level =	DEFAULT_GUC_LOG_LEVEL,
 38	.force_probe =		DEFAULT_FORCE_PROBE,
 39#ifdef CONFIG_PCI_IOV
 40	.max_vfs =		DEFAULT_MAX_VFS,
 41#endif
 42	.wedged_mode =		DEFAULT_WEDGED_MODE,
 43	.svm_notifier_size =	DEFAULT_SVM_NOTIFIER_SIZE,
 44	/* the rest are 0 by default */
 45};
 46
 47module_param_named(svm_notifier_size, xe_modparam.svm_notifier_size, uint, 0600);
 48MODULE_PARM_DESC(svm_notifier_size, "Set the svm notifier size in MiB, must be power of 2 "
 49		 "[default=" __stringify(DEFAULT_SVM_NOTIFIER_SIZE) "]");
 50
 51module_param_named_unsafe(force_execlist, xe_modparam.force_execlist, bool, 0444);
 52MODULE_PARM_DESC(force_execlist, "Force Execlist submission");
 53
 54module_param_named(probe_display, xe_modparam.probe_display, bool, 0444);
 55MODULE_PARM_DESC(probe_display, "Probe display HW, otherwise it's left untouched "
 56		 "[default=" __stringify(DEFAULT_PROBE_DISPLAY) "])");
 57
 58module_param_named(vram_bar_size, xe_modparam.force_vram_bar_size, int, 0600);
 59MODULE_PARM_DESC(vram_bar_size, "Set the vram bar size in MiB (<0=disable-resize, 0=max-needed-size, >0=force-size "
 60		 "[default=" __stringify(DEFAULT_VRAM_BAR_SIZE) "])");
 61
 62module_param_named(guc_log_level, xe_modparam.guc_log_level, int, 0600);
 63MODULE_PARM_DESC(guc_log_level, "GuC firmware logging level (0=disable, 1=normal, 2..5=verbose-levels "
 64		 "[default=" __stringify(DEFAULT_GUC_LOG_LEVEL) "])");
 65
 66module_param_named_unsafe(guc_firmware_path, xe_modparam.guc_firmware_path, charp, 0400);
 67MODULE_PARM_DESC(guc_firmware_path,
 68		 "GuC firmware path to use instead of the default one");
 69
 70module_param_named_unsafe(huc_firmware_path, xe_modparam.huc_firmware_path, charp, 0400);
 71MODULE_PARM_DESC(huc_firmware_path,
 72		 "HuC firmware path to use instead of the default one - empty string disables");
 73
 74module_param_named_unsafe(gsc_firmware_path, xe_modparam.gsc_firmware_path, charp, 0400);
 75MODULE_PARM_DESC(gsc_firmware_path,
 76		 "GSC firmware path to use instead of the default one - empty string disables");
 77
 78module_param_named_unsafe(force_probe, xe_modparam.force_probe, charp, 0400);
 79MODULE_PARM_DESC(force_probe,
 80		 "Force probe options for specified devices. See CONFIG_DRM_XE_FORCE_PROBE for details "
 81		 "[default=" DEFAULT_FORCE_PROBE "])");
 82
 83#ifdef CONFIG_PCI_IOV
 84module_param_named(max_vfs, xe_modparam.max_vfs, uint, 0400);
 85MODULE_PARM_DESC(max_vfs,
 86		 "Limit number of Virtual Functions (VFs) that could be managed. "
 87		 "(0=no VFs; N=allow up to N VFs "
 88		 "[default=" DEFAULT_MAX_VFS_STR "])");
 89#endif
 90
 91module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600);
 92MODULE_PARM_DESC(wedged_mode,
 93		 "Module's default policy for the wedged mode (0=never, 1=upon-critical-errors, 2=upon-any-hang "
 94		 "[default=" __stringify(DEFAULT_WEDGED_MODE) "])");
 95
 96static int xe_check_nomodeset(void)
 97{
 98	if (drm_firmware_drivers_only())
 99		return -ENODEV;
100
101	return 0;
102}
103
104struct init_funcs {
105	int (*init)(void);
106	void (*exit)(void);
107};
108
109static const struct init_funcs init_funcs[] = {
110	{
111		.init = xe_check_nomodeset,
112	},
113	{
114		.init = xe_configfs_init,
115		.exit = xe_configfs_exit,
116	},
117	{
118		.init = xe_hw_fence_module_init,
119		.exit = xe_hw_fence_module_exit,
120	},
121	{
122		.init = xe_sched_job_module_init,
123		.exit = xe_sched_job_module_exit,
124	},
125	{
126		.init = xe_register_pci_driver,
127		.exit = xe_unregister_pci_driver,
128	},
129	{
130		.init = xe_observation_sysctl_register,
131		.exit = xe_observation_sysctl_unregister,
132	},
133	{
134		.init = xe_pm_module_init,
135	},
136};
137
138static int __init xe_call_init_func(const struct init_funcs *func)
139{
140	if (func->init)
141		return func->init();
142	return 0;
143}
144
145static void xe_call_exit_func(const struct init_funcs *func)
146{
147	if (func->exit)
148		func->exit();
149}
150
151static int __init xe_init(void)
152{
153	int err, i;
154
155	for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
156		err = xe_call_init_func(init_funcs + i);
157		if (err) {
158			pr_info("%s: module_init aborted at %ps %pe\n",
159				DRIVER_NAME, init_funcs[i].init, ERR_PTR(err));
160			while (i--)
161				xe_call_exit_func(init_funcs + i);
162			return err;
163		}
164	}
165
166	return 0;
167}
168
169static void __exit xe_exit(void)
170{
171	int i;
172
173	for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
174		xe_call_exit_func(init_funcs + i);
175}
176
177module_init(xe_init);
178module_exit(xe_exit);
179
180MODULE_AUTHOR("Intel Corporation");
181
182MODULE_DESCRIPTION(DRIVER_DESC);
183MODULE_LICENSE("GPL and additional rights");
~/ Read-only file preview.