Skip to content

Commit 014125c

Browse files
Thomas Zimmermannlucasdemarchi
authored andcommitted
drm/xe: Support 'nomodeset' kernel command-line option
Setting 'nomodeset' on the kernel command line disables all graphics drivers with modesetting capabilities, leaving only firmware drivers, such as simpledrm or efifb. Most DRM drivers automatically support 'nomodeset' via DRM's module helper macros. In xe, which uses regular module_init(), manually call drm_firmware_drivers_only() to test for 'nomodeset'. Do not register the driver if set. v2: - use xe's init table (Lucas) - do NULL test for init/exit functions Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 8a04e34 commit 014125c

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

drivers/gpu/drm/xe/xe_module.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/init.h>
99
#include <linux/module.h>
1010

11+
#include <drm/drm_module.h>
12+
1113
#include "xe_drv.h"
1214
#include "xe_hw_fence.h"
1315
#include "xe_pci.h"
@@ -61,12 +63,23 @@ module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600);
6163
MODULE_PARM_DESC(wedged_mode,
6264
"Module's default policy for the wedged mode - 0=never, 1=upon-critical-errors[default], 2=upon-any-hang");
6365

66+
static int xe_check_nomodeset(void)
67+
{
68+
if (drm_firmware_drivers_only())
69+
return -ENODEV;
70+
71+
return 0;
72+
}
73+
6474
struct init_funcs {
6575
int (*init)(void);
6676
void (*exit)(void);
6777
};
6878

6979
static const struct init_funcs init_funcs[] = {
80+
{
81+
.init = xe_check_nomodeset,
82+
},
7083
{
7184
.init = xe_hw_fence_module_init,
7285
.exit = xe_hw_fence_module_exit,
@@ -85,15 +98,35 @@ static const struct init_funcs init_funcs[] = {
8598
},
8699
};
87100

101+
static int __init xe_call_init_func(unsigned int i)
102+
{
103+
if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
104+
return 0;
105+
if (!init_funcs[i].init)
106+
return 0;
107+
108+
return init_funcs[i].init();
109+
}
110+
111+
static void xe_call_exit_func(unsigned int i)
112+
{
113+
if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
114+
return;
115+
if (!init_funcs[i].exit)
116+
return;
117+
118+
init_funcs[i].exit();
119+
}
120+
88121
static int __init xe_init(void)
89122
{
90123
int err, i;
91124

92125
for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
93-
err = init_funcs[i].init();
126+
err = xe_call_init_func(i);
94127
if (err) {
95128
while (i--)
96-
init_funcs[i].exit();
129+
xe_call_exit_func(i);
97130
return err;
98131
}
99132
}
@@ -106,7 +139,7 @@ static void __exit xe_exit(void)
106139
int i;
107140

108141
for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
109-
init_funcs[i].exit();
142+
xe_call_exit_func(i);
110143
}
111144

112145
module_init(xe_init);

0 commit comments

Comments
 (0)