drm/fbdev: Move fbdev module parameters next to module init

Define the parameters for fbdev emulation in the source file with the
module-initialization and exit code of drm_kms_helper.ko. The parameters
control some aspects of DRM's fbdev emulation. Common usage looks like

  drm_kms_helper.drm_fbdev_overalloc=200

on the kernel's command line. This has been possible for many years
and changing it would likely upset users.

The emulation code is supposed to be moved into the module for DRM
clients. Keeping the parameters in drm_kms_helper.ko avoids breaking
systems the use them in the way described above.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patch.msgid.link/20260928080323.23909-2-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2026-09-28 10:01:24 +02:00
parent 25854efccd
commit 6b5a66fd9f
3 changed files with 49 additions and 31 deletions

View File

@ -29,6 +29,8 @@
#ifndef __DRM_CRTC_HELPER_INTERNAL_H__
#define __DRM_CRTC_HELPER_INTERNAL_H__
#include <linux/types.h>
enum drm_mode_status;
struct drm_connector;
struct drm_crtc;
@ -36,6 +38,13 @@ struct drm_display_mode;
struct drm_encoder;
struct drm_modeset_acquire_ctx;
/* drm_kms_helper_common.c */
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
extern bool drm_fbdev_emulation;
extern int drm_fbdev_overalloc;
extern bool drm_leak_fbdev_smem;
#endif
/* drm_probe_helper.c */
enum drm_mode_status drm_crtc_mode_valid(struct drm_crtc *crtc,
const struct drm_display_mode *mode);

View File

@ -43,39 +43,9 @@
#include <drm/drm_vblank.h>
#include "drm_internal.h"
#include "drm_crtc_helper_internal.h"
#include "drm_crtc_internal.h"
static bool drm_fbdev_emulation = true;
module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
MODULE_PARM_DESC(fbdev_emulation,
"Enable legacy fbdev emulation [default=true]");
static int drm_fbdev_overalloc = CONFIG_DRM_FBDEV_OVERALLOC;
module_param(drm_fbdev_overalloc, int, 0444);
MODULE_PARM_DESC(drm_fbdev_overalloc,
"Overallocation of the fbdev buffer (%) [default="
__MODULE_STRING(CONFIG_DRM_FBDEV_OVERALLOC) "]");
/*
* In order to keep user-space compatibility, we want in certain use-cases
* to keep leaking the fbdev physical address to the user-space program
* handling the fbdev buffer.
*
* This is a bad habit, essentially kept to support closed-source OpenGL
* drivers that should really be moved into open-source upstream projects
* instead of using legacy physical addresses in user space to communicate
* with other out-of-tree kernel modules.
*
* This module_param *should* be removed as soon as possible and be
* considered as a broken and legacy behaviour from a modern fbdev device.
*/
static bool drm_leak_fbdev_smem;
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
MODULE_PARM_DESC(drm_leak_fbdev_smem,
"Allow unsafe leaking fbdev physical smem address [default=false]");
#endif
/**
* DOC: fbdev helpers
*

View File

@ -25,10 +25,49 @@
*
*/
#include <linux/export.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include "drm_crtc_helper_internal.h"
#include "drm_panic_internal.h"
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
bool drm_fbdev_emulation = true;
EXPORT_SYMBOL(drm_fbdev_emulation);
module_param_named(fbdev_emulation, drm_fbdev_emulation, bool, 0600);
MODULE_PARM_DESC(fbdev_emulation, "Enable legacy fbdev emulation [default=true]");
int drm_fbdev_overalloc = CONFIG_DRM_FBDEV_OVERALLOC;
EXPORT_SYMBOL(drm_fbdev_overalloc);
module_param(drm_fbdev_overalloc, int, 0444);
MODULE_PARM_DESC(drm_fbdev_overalloc,
"Overallocation of the fbdev buffer (%) [default="
__MODULE_STRING(CONFIG_DRM_FBDEV_OVERALLOC) "]");
/*
* In order to keep user-space compatibility, we want in certain use-cases
* to keep leaking the fbdev physical address to the user-space program
* handling the fbdev buffer.
*
* This is a bad habit, essentially kept to support closed-source OpenGL
* drivers that should really be moved into open-source upstream projects
* instead of using legacy physical addresses in user space to communicate
* with other out-of-tree kernel modules.
*
* This module_param *should* be removed as soon as possible and be
* considered as a broken and legacy behaviour from a modern fbdev device.
*/
bool drm_leak_fbdev_smem;
EXPORT_SYMBOL(drm_leak_fbdev_smem);
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
MODULE_PARM_DESC(drm_leak_fbdev_smem,
"Allow unsafe leaking fbdev physical smem address [default=false]");
#endif
#endif
static int __init drm_kms_helper_init(void)
{
return drm_panic_helper_init();