drm: Move nomodeset kernel parameter to drivers/video
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 11 Nov 2022 13:30:23 +0000 (14:30 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 16 Nov 2022 12:26:12 +0000 (13:26 +0100)
Move the nomodeset kernel parameter to drivers/video to make it
available to non-DRM drivers. Adapt the interface, but keep the DRM
interface drm_firmware_drivers_only() to avoid churn within DRM. The
function should later be inlined into callers.

The parameter disables any DRM graphics driver that would replace a
driver for firmware-provided scanout buffers. It is an option to easily
fallback to basic graphics output if the hardware's native driver is
broken. Moving it to a more prominent location wil make it available
to fbdev as well.

v2:
* clarify the meaning of the nomodeset parameter (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221111133024.9897-2-tzimmermann@suse.de
Documentation/admin-guide/kernel-parameters.txt
MAINTAINERS
drivers/gpu/drm/Kconfig
drivers/gpu/drm/Makefile
drivers/gpu/drm/drm_nomodeset.c [deleted file]
drivers/video/Kconfig
drivers/video/Makefile
drivers/video/nomodeset.c [new file with mode: 0644]
include/drm/drm_drv.h
include/video/nomodeset.h [new file with mode: 0644]

index a465d5242774af8f89779121b5acca4439b7f5f0..88561b3ce28a407adfce679fce6bd7ed85ae0cc8 100644 (file)
                        shutdown the other cpus.  Instead use the REBOOT_VECTOR
                        irq.
 
-       nomodeset       Disable kernel modesetting. DRM drivers will not perform
-                       display-mode changes or accelerated rendering. Only the
-                       system framebuffer will be available for use if this was
-                       set-up by the firmware or boot loader.
-
-                       Useful as fallback, or for testing and debugging.
+       nomodeset       Disable kernel modesetting. Most systems' firmware
+                       sets up a display mode and provides framebuffer memory
+                       for output. With nomodeset, DRM and fbdev drivers will
+                       not load if they could possibly displace the pre-
+                       initialized output. Only the system framebuffer will
+                       be available for use. The respective drivers will not
+                       perform display-mode changes or accelerated rendering.
+
+                       Useful as error fallback, or for testing and debugging.
 
        nomodule        Disable module load
 
index 178a7a383b5fc3f95203fe6514c7f29970f347f3..7dc3b719b2a24c07b89987effa5f35243ebff921 100644 (file)
@@ -6701,8 +6701,10 @@ F:       drivers/gpu/drm/drm_aperture.c
 F:     drivers/gpu/drm/tiny/ofdrm.c
 F:     drivers/gpu/drm/tiny/simpledrm.c
 F:     drivers/video/aperture.c
+F:     drivers/video/nomodeset.c
 F:     include/drm/drm_aperture.h
 F:     include/linux/aperture.h
+F:     include/video/nomodeset.h
 
 DRM DRIVER FOR SIS VIDEO CARDS
 S:     Orphan / Obsolete
index 34f5a092c99e72f3a3b8744fa5b71f80de96e9b6..722ded62639913a5626ad5e2d999a246ff01b667 100644 (file)
@@ -8,7 +8,6 @@
 menuconfig DRM
        tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
        depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
-       select DRM_NOMODESET
        select DRM_PANEL_ORIENTATION_QUIRKS
        select HDMI
        select FB_CMDLINE
@@ -19,6 +18,7 @@ menuconfig DRM
 # gallium uses SYS_kcmp for os_same_file_description() to de-duplicate
 # device and dmabuf fd. Let's make sure that is available for our userspace.
        select KCMP
+       select VIDEO_NOMODESET
        help
          Kernel-level support for the Direct Rendering Infrastructure (DRI)
          introduced in XFree86 4.0. If you say Y here, you need to select
@@ -514,11 +514,6 @@ config DRM_EXPORT_FOR_TESTS
 config DRM_PANEL_ORIENTATION_QUIRKS
        tristate
 
-# Separate option because nomodeset parameter is global and expected built-in
-config DRM_NOMODESET
-       bool
-       default n
-
 config DRM_LIB_RANDOM
        bool
        default n
index c44a54cadb618f4948abbaca2ce889f6f08633ea..f92cd78927110abe9aba56e63461f90a43fa27e9 100644 (file)
@@ -72,7 +72,6 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
        drm_privacy_screen_x86.o
 obj-$(CONFIG_DRM)      += drm.o
 
-obj-$(CONFIG_DRM_NOMODESET) += drm_nomodeset.o
 obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 
 #
diff --git a/drivers/gpu/drm/drm_nomodeset.c b/drivers/gpu/drm/drm_nomodeset.c
deleted file mode 100644 (file)
index f3978d5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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("Booted with the nomodeset parameter. Only the system framebuffer will be available\n");
-
-       return 1;
-}
-
-/* Disable kernel modesetting */
-__setup("nomodeset", disable_modeset);
index 0587e21abad943af21d2495d544f3e2e604f0c5b..6d2fde6c5d11a18ab02c5d6893020c17a10f309d 100644 (file)
@@ -11,6 +11,10 @@ config APERTURE_HELPERS
          Support tracking and hand-over of aperture ownership. Required
          by graphics drivers for firmware-provided framebuffers.
 
+config VIDEO_NOMODESET
+       bool
+       default n
+
 if HAS_IOMEM
 
 config HAVE_FB_ATMEL
index 5bb6b452cc83a1580382f3a5be73a1e6f3ab0e0f..a50eb528ed3c3a0778516bd38a4944a21b9d3386 100644 (file)
@@ -2,6 +2,7 @@
 
 obj-$(CONFIG_APERTURE_HELPERS)    += aperture.o
 obj-$(CONFIG_VGASTATE)            += vgastate.o
+obj-$(CONFIG_VIDEO_NOMODESET)     += nomodeset.o
 obj-$(CONFIG_HDMI)                += hdmi.o
 
 obj-$(CONFIG_VT)                 += console/
diff --git a/drivers/video/nomodeset.c b/drivers/video/nomodeset.c
new file mode 100644 (file)
index 0000000..13cc8b7
--- /dev/null
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/module.h>
+#include <linux/types.h>
+
+#include <video/nomodeset.h>
+
+static bool video_nomodeset;
+
+bool video_firmware_drivers_only(void)
+{
+       return video_nomodeset;
+}
+EXPORT_SYMBOL(video_firmware_drivers_only);
+
+static int __init disable_modeset(char *str)
+{
+       video_nomodeset = true;
+
+       pr_warn("Booted with the nomodeset parameter. Only the system framebuffer will be available\n");
+
+       return 1;
+}
+
+/* Disable kernel modesetting */
+__setup("nomodeset", disable_modeset);
index f6159acb885695d65ff84b4f7380d9c7feb301c9..700d3857e0881582ea6ed45c154b7dfc629cd6c7 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/list.h>
 #include <linux/irqreturn.h>
 
+#include <video/nomodeset.h>
+
 #include <drm/drm_device.h>
 
 struct drm_file;
@@ -602,6 +604,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);
 
-extern bool drm_firmware_drivers_only(void);
+/* TODO: Inline drm_firmware_drivers_only() in all its callers. */
+static inline bool drm_firmware_drivers_only(void)
+{
+       return video_firmware_drivers_only();
+}
 
 #endif
diff --git a/include/video/nomodeset.h b/include/video/nomodeset.h
new file mode 100644 (file)
index 0000000..8f8688b
--- /dev/null
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef VIDEO_NOMODESET_H
+#define VIDEO_NOMODESET_H
+
+bool video_firmware_drivers_only(void);
+
+#endif