Skip to content

Commit a51c766

Browse files
author
Thomas Zimmermann
committed
drm/fb-helper: Consolidate CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM
Consolidate all handling of CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM by making the module parameter optional in drm_fb_helper.c. Without the config option, modules can set smem_start in struct fb_info for internal usage, but not export if to userspace. The address can only be exported by enabling the option and setting the module parameter. Also update the comment. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Acked-by: Zack Rusin <[email protected]> Tested-by: Sui Jingfeng<[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 61b5d00 commit a51c766

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ MODULE_PARM_DESC(drm_fbdev_overalloc,
6060
* In order to keep user-space compatibility, we want in certain use-cases
6161
* to keep leaking the fbdev physical address to the user-space program
6262
* handling the fbdev buffer.
63-
* This is a bad habit essentially kept into closed source opengl driver
64-
* that should really be moved into open-source upstream projects instead
65-
* of using legacy physical addresses in user space to communicate with
66-
* other out-of-tree kernel modules.
63+
*
64+
* This is a bad habit, essentially kept to support closed-source OpenGL
65+
* drivers that should really be moved into open-source upstream projects
66+
* instead of using legacy physical addresses in user space to communicate
67+
* with other out-of-tree kernel modules.
6768
*
6869
* This module_param *should* be removed as soon as possible and be
6970
* considered as a broken and legacy behaviour from a modern fbdev device.
7071
*/
71-
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
7272
static bool drm_leak_fbdev_smem;
73+
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
7374
module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
7475
MODULE_PARM_DESC(drm_leak_fbdev_smem,
7576
"Allow unsafe leaking fbdev physical smem address [default=false]");
@@ -1983,10 +1984,6 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper)
19831984
return ret;
19841985
}
19851986

1986-
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
1987-
fb_helper->hint_leak_smem_start = drm_leak_fbdev_smem;
1988-
#endif
1989-
19901987
/* push down into drivers */
19911988
ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
19921989
if (ret < 0)
@@ -2185,11 +2182,8 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
21852182

21862183
info = fb_helper->info;
21872184
info->var.pixclock = 0;
2188-
/* Shamelessly allow physical address leaking to userspace */
2189-
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
2190-
if (!fb_helper->hint_leak_smem_start)
2191-
#endif
2192-
/* don't leak any physical addresses to userspace */
2185+
2186+
if (!drm_leak_fbdev_smem)
21932187
info->flags |= FBINFO_HIDE_SMEM_START;
21942188

21952189
/* Need to drop locks to avoid recursive deadlock in

drivers/gpu/drm/drm_fbdev_dma.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,9 @@ static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper,
136136
info->flags |= FBINFO_READS_FAST; /* signal caching */
137137
info->screen_size = sizes->surface_height * fb->pitches[0];
138138
info->screen_buffer = map.vaddr;
139+
info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer));
139140
info->fix.smem_len = info->screen_size;
140141

141-
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
142-
/*
143-
* Shamelessly leak the physical address to user-space.
144-
*/
145-
if (fb_helper->hint_leak_smem_start && !info->fix.smem_start)
146-
info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer));
147-
#endif
148-
149142
return 0;
150143

151144
err_drm_client_buffer_vunmap:

include/drm/drm_fb_helper.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,6 @@ struct drm_fb_helper {
195195
*/
196196
int preferred_bpp;
197197

198-
/**
199-
* @hint_leak_smem_start:
200-
*
201-
* Hint to the fbdev emulation to store the framebuffer's physical
202-
* address in struct &fb_info.fix.smem_start. If the hint is unset,
203-
* the smem_start field should always be cleared to zero.
204-
*/
205-
bool hint_leak_smem_start;
206-
207198
#ifdef CONFIG_FB_DEFERRED_IO
208199
/**
209200
* @fbdefio:

0 commit comments

Comments
 (0)