drm: Move nomodeset kernel parameter to the DRM subsystem

The "nomodeset" kernel cmdline parameter is handled by the vgacon driver
but the exported vgacon_text_force() symbol is only used by DRM drivers.

It makes much more sense for the parameter logic to be in the subsystem
of the drivers that are making use of it.

Let's move the vgacon_text_force() function and related logic to the DRM
subsystem. While doing that, rename it to drm_firmware_drivers_only() and
make it return true if "nomodeset" was used and false otherwise. This is
a better description of the condition that the drivers are testing for.
Suggested-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Acked-by: default avatarPekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211112133230.1595307-4-javierm@redhat.com
parent d76f25d6
...@@ -33,6 +33,8 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86. ...@@ -33,6 +33,8 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86.
obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o
obj-$(CONFIG_VGA_CONSOLE) += drm_nomodeset.o
drm_cma_helper-y := drm_gem_cma_helper.o drm_cma_helper-y := drm_gem_cma_helper.o
obj-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_cma_helper.o obj-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_cma_helper.o
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "amdgpu_drv.h" #include "amdgpu_drv.h"
#include <drm/drm_pciids.h> #include <drm/drm_pciids.h>
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
...@@ -2516,7 +2515,7 @@ static int __init amdgpu_init(void) ...@@ -2516,7 +2515,7 @@ static int __init amdgpu_init(void)
{ {
int r; int r;
if (vgacon_text_force()) if (drm_firmware_drivers_only())
return -EINVAL; return -EINVAL;
r = amdgpu_sync_init(); r = amdgpu_sync_init();
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* Authors: Dave Airlie <airlied@redhat.com> * Authors: Dave Airlie <airlied@redhat.com>
*/ */
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -233,7 +232,7 @@ static struct pci_driver ast_pci_driver = { ...@@ -233,7 +232,7 @@ static struct pci_driver ast_pci_driver = {
static int __init ast_init(void) static int __init ast_init(void)
{ {
if (vgacon_text_force() && ast_modeset == -1) if (drm_firmware_drivers_only() && ast_modeset == -1)
return -EINVAL; return -EINVAL;
if (ast_modeset == 0) if (ast_modeset == 0)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright © 2021 Intel Corporation * Copyright © 2021 Intel Corporation
*/ */
#include <linux/console.h> #include <drm/drm_drv.h>
#include "gem/i915_gem_context.h" #include "gem/i915_gem_context.h"
#include "gem/i915_gem_object.h" #include "gem/i915_gem_object.h"
...@@ -31,7 +31,7 @@ static int i915_check_nomodeset(void) ...@@ -31,7 +31,7 @@ static int i915_check_nomodeset(void)
if (i915_modparams.modeset == 0) if (i915_modparams.modeset == 0)
use_kms = false; use_kms = false;
if (vgacon_text_force() && i915_modparams.modeset == -1) if (drm_firmware_drivers_only() && i915_modparams.modeset == -1)
use_kms = false; use_kms = false;
if (!use_kms) { if (!use_kms) {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
* Dave Airlie * Dave Airlie
*/ */
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -378,7 +377,7 @@ static struct pci_driver mgag200_pci_driver = { ...@@ -378,7 +377,7 @@ static struct pci_driver mgag200_pci_driver = {
static int __init mgag200_init(void) static int __init mgag200_init(void)
{ {
if (vgacon_text_force() && mgag200_modeset == -1) if (drm_firmware_drivers_only() && mgag200_modeset == -1)
return -EINVAL; return -EINVAL;
if (mgag200_modeset == 0) if (mgag200_modeset == 0)
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
* Authors: Ben Skeggs * Authors: Ben Skeggs
*/ */
#include <linux/console.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -32,6 +31,7 @@ ...@@ -32,6 +31,7 @@
#include <drm/drm_aperture.h> #include <drm/drm_aperture.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_gem_ttm_helper.h> #include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h> #include <drm/drm_ioctl.h>
#include <drm/drm_vblank.h> #include <drm/drm_vblank.h>
...@@ -1358,7 +1358,7 @@ nouveau_drm_init(void) ...@@ -1358,7 +1358,7 @@ nouveau_drm_init(void)
nouveau_display_options(); nouveau_display_options();
if (nouveau_modeset == -1) { if (nouveau_modeset == -1) {
if (vgacon_text_force()) if (drm_firmware_drivers_only())
nouveau_modeset = 0; nouveau_modeset = 0;
} }
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "qxl_drv.h" #include "qxl_drv.h"
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/vgaarb.h> #include <linux/vgaarb.h>
...@@ -295,7 +294,7 @@ static struct drm_driver qxl_driver = { ...@@ -295,7 +294,7 @@ static struct drm_driver qxl_driver = {
static int __init qxl_init(void) static int __init qxl_init(void)
{ {
if (vgacon_text_force() && qxl_modeset == -1) if (drm_firmware_drivers_only() && qxl_modeset == -1)
return -EINVAL; return -EINVAL;
if (qxl_modeset == 0) if (qxl_modeset == 0)
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
...@@ -637,7 +636,7 @@ static struct pci_driver radeon_kms_pci_driver = { ...@@ -637,7 +636,7 @@ static struct pci_driver radeon_kms_pci_driver = {
static int __init radeon_module_init(void) static int __init radeon_module_init(void)
{ {
if (vgacon_text_force() && radeon_modeset == -1) if (drm_firmware_drivers_only() && radeon_modeset == -1)
radeon_modeset = 0; radeon_modeset = 0;
if (radeon_modeset == 0) if (radeon_modeset == 0)
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/console.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <drm/drm_aperture.h> #include <drm/drm_aperture.h>
...@@ -719,7 +718,7 @@ static struct pci_driver bochs_pci_driver = { ...@@ -719,7 +718,7 @@ static struct pci_driver bochs_pci_driver = {
static int __init bochs_init(void) static int __init bochs_init(void)
{ {
if (vgacon_text_force() && bochs_modeset == -1) if (drm_firmware_drivers_only() && bochs_modeset == -1)
return -EINVAL; return -EINVAL;
if (bochs_modeset == 0) if (bochs_modeset == 0)
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com> * Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>
*/ */
#include <linux/console.h>
#include <linux/dma-buf-map.h> #include <linux/dma-buf-map.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -636,8 +635,9 @@ static struct pci_driver cirrus_pci_driver = { ...@@ -636,8 +635,9 @@ static struct pci_driver cirrus_pci_driver = {
static int __init cirrus_init(void) static int __init cirrus_init(void)
{ {
if (vgacon_text_force()) if (drm_firmware_drivers_only())
return -EINVAL; return -EINVAL;
return pci_register_driver(&cirrus_pci_driver); return pci_register_driver(&cirrus_pci_driver);
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* Michael Thayer <michael.thayer@oracle.com, * Michael Thayer <michael.thayer@oracle.com,
* Hans de Goede <hdegoede@redhat.com> * Hans de Goede <hdegoede@redhat.com>
*/ */
#include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/vt_kern.h> #include <linux/vt_kern.h>
...@@ -193,7 +192,7 @@ static const struct drm_driver driver = { ...@@ -193,7 +192,7 @@ static const struct drm_driver driver = {
static int __init vbox_init(void) static int __init vbox_init(void)
{ {
if (vgacon_text_force() && vbox_modeset == -1) if (drm_firmware_drivers_only() && vbox_modeset == -1)
return -EINVAL; return -EINVAL;
if (vbox_modeset == 0) if (vbox_modeset == 0)
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/console.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -104,7 +103,7 @@ static int virtio_gpu_probe(struct virtio_device *vdev) ...@@ -104,7 +103,7 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
struct drm_device *dev; struct drm_device *dev;
int ret; int ret;
if (vgacon_text_force() && virtio_gpu_modeset == -1) if (drm_firmware_drivers_only() && virtio_gpu_modeset == -1)
return -EINVAL; return -EINVAL;
if (virtio_gpu_modeset == 0) if (virtio_gpu_modeset == 0)
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* *
**************************************************************************/ **************************************************************************/
#include <linux/console.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -1651,7 +1650,7 @@ static int __init vmwgfx_init(void) ...@@ -1651,7 +1650,7 @@ static int __init vmwgfx_init(void)
{ {
int ret; int ret;
if (vgacon_text_force()) if (drm_firmware_drivers_only())
return -EINVAL; return -EINVAL;
ret = pci_register_driver(&vmw_pci_driver); ret = pci_register_driver(&vmw_pci_driver);
......
...@@ -97,30 +97,9 @@ static int vga_video_font_height; ...@@ -97,30 +97,9 @@ static int vga_video_font_height;
static int vga_scan_lines __read_mostly; static int vga_scan_lines __read_mostly;
static unsigned int vga_rolled_over; /* last vc_origin offset before wrap */ static unsigned int vga_rolled_over; /* last vc_origin offset before wrap */
static bool vgacon_text_mode_force;
static bool vga_hardscroll_enabled; static bool vga_hardscroll_enabled;
static bool vga_hardscroll_user_enable = true; static bool vga_hardscroll_user_enable = true;
bool vgacon_text_force(void)
{
return vgacon_text_mode_force;
}
EXPORT_SYMBOL(vgacon_text_force);
static int __init text_mode(char *str)
{
vgacon_text_mode_force = true;
pr_warn("You have booted with nomodeset. This means your GPU drivers are DISABLED\n");
pr_warn("Any video related functionality will be severely degraded, and you may not even be able to suspend the system properly\n");
pr_warn("Unless you actually understand what nomodeset does, you should reboot without enabling it\n");
return 1;
}
/* force text mode - used by kernel modesetting */
__setup("nomodeset", text_mode);
static int __init no_scroll(char *str) static int __init no_scroll(char *str)
{ {
/* /*
......
// SPDX-License-Identifier: GPL-2.0
#include <linux/module.h>
#include <linux/types.h>
static bool drm_nomodeset;
bool drm_firmware_drivers_only(void)
{
return drm_nomodeset;
}
EXPORT_SYMBOL(drm_firmware_drivers_only);
static int __init disable_modeset(char *str)
{
drm_nomodeset = true;
pr_warn("You have booted with nomodeset. This means your GPU drivers are DISABLED\n");
pr_warn("Any video related functionality will be severely degraded, and you may not even be able to suspend the system properly\n");
pr_warn("Unless you actually understand what nomodeset does, you should reboot without enabling it\n");
return 1;
}
/* Disable kernel modesetting */
__setup("nomodeset", disable_modeset);
...@@ -601,5 +601,10 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) ...@@ -601,5 +601,10 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
int drm_dev_set_unique(struct drm_device *dev, const char *name); int drm_dev_set_unique(struct drm_device *dev, const char *name);
#ifdef CONFIG_VGA_CONSOLE
extern bool drm_firmware_drivers_only(void);
#else
static inline bool drm_firmware_drivers_only(void) { return false; }
#endif
#endif #endif
...@@ -219,12 +219,6 @@ extern atomic_t ignore_console_lock_warning; ...@@ -219,12 +219,6 @@ extern atomic_t ignore_console_lock_warning;
#define VESA_HSYNC_SUSPEND 2 #define VESA_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3 #define VESA_POWERDOWN 3
#ifdef CONFIG_VGA_CONSOLE
extern bool vgacon_text_force(void);
#else
static inline bool vgacon_text_force(void) { return false; }
#endif
extern void console_init(void); extern void console_init(void);
/* For deferred console takeover */ /* For deferred console takeover */
......
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