Commit 014125c6 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Lucas De Marchi

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240827121003.97429-1-tzimmermann@suse.deSigned-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 8a04e342
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <drm/drm_module.h>
#include "xe_drv.h" #include "xe_drv.h"
#include "xe_hw_fence.h" #include "xe_hw_fence.h"
#include "xe_pci.h" #include "xe_pci.h"
...@@ -61,12 +63,23 @@ module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600); ...@@ -61,12 +63,23 @@ module_param_named_unsafe(wedged_mode, xe_modparam.wedged_mode, int, 0600);
MODULE_PARM_DESC(wedged_mode, MODULE_PARM_DESC(wedged_mode,
"Module's default policy for the wedged mode - 0=never, 1=upon-critical-errors[default], 2=upon-any-hang"); "Module's default policy for the wedged mode - 0=never, 1=upon-critical-errors[default], 2=upon-any-hang");
static int xe_check_nomodeset(void)
{
if (drm_firmware_drivers_only())
return -ENODEV;
return 0;
}
struct init_funcs { struct init_funcs {
int (*init)(void); int (*init)(void);
void (*exit)(void); void (*exit)(void);
}; };
static const struct init_funcs init_funcs[] = { static const struct init_funcs init_funcs[] = {
{
.init = xe_check_nomodeset,
},
{ {
.init = xe_hw_fence_module_init, .init = xe_hw_fence_module_init,
.exit = xe_hw_fence_module_exit, .exit = xe_hw_fence_module_exit,
...@@ -85,15 +98,35 @@ static const struct init_funcs init_funcs[] = { ...@@ -85,15 +98,35 @@ static const struct init_funcs init_funcs[] = {
}, },
}; };
static int __init xe_call_init_func(unsigned int i)
{
if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
return 0;
if (!init_funcs[i].init)
return 0;
return init_funcs[i].init();
}
static void xe_call_exit_func(unsigned int i)
{
if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
return;
if (!init_funcs[i].exit)
return;
init_funcs[i].exit();
}
static int __init xe_init(void) static int __init xe_init(void)
{ {
int err, i; int err, i;
for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
err = init_funcs[i].init(); err = xe_call_init_func(i);
if (err) { if (err) {
while (i--) while (i--)
init_funcs[i].exit(); xe_call_exit_func(i);
return err; return err;
} }
} }
...@@ -106,7 +139,7 @@ static void __exit xe_exit(void) ...@@ -106,7 +139,7 @@ static void __exit xe_exit(void)
int i; int i;
for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--) for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
init_funcs[i].exit(); xe_call_exit_func(i);
} }
module_init(xe_init); module_init(xe_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment