From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: LKML <linux-kernel@vger.kernel.org>
Cc: "Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
"DRI Development" <dri-devel@lists.freedesktop.org>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Daniel Vetter" <daniel.vetter@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Yisheng Xie" <ysxie@foxmail.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Peter Rosin" <peda@axentia.se>,
"Mikulas Patocka" <mpatocka@redhat.com>
Subject: [PATCH 30/33] fbcon: Call con2fb_map functions directly
Date: Fri, 24 May 2019 10:53:51 +0200 [thread overview]
Message-ID: <20190524085354.27411-31-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20190524085354.27411-1-daniel.vetter@ffwll.ch>
These are actually fbcon ioctls which just happen to be exposed
through /dev/fb*. They completely ignore which fb_info they're called
on, and I think the userspace tool even hardcodes to /dev/fb0.
Hence just forward the entire thing to fbcon.c wholesale.
Note that this patch drops the fb_lock/unlock on the set side. Since
the ioctl can operate on any fb (as passed in through
con2fb.framebuffer) this is bogus. Also note that fbcon.c in general
never calls fb_lock on anything, so this has been badly broken
already.
With this the last user of the fbcon notifier callback is gone, and we
can garbage collect that too.
v2: add missing uaccess.h include (alpha fails to compile otherwise),
reported by kbuild.
v3: Remember to also drop the #defines (Maarten)
v4: Add the static inline to dummy functions.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Yisheng Xie <ysxie@foxmail.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Peter Rosin <peda@axentia.se>
Cc: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/video/fbdev/core/fbcon.c | 59 +++++++++++++++++++-------------
drivers/video/fbdev/core/fbmem.c | 34 ++----------------
include/linux/fb.h | 4 ---
include/linux/fbcon.h | 4 +++
4 files changed, 42 insertions(+), 59 deletions(-)
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index e08e984e2511..6a4bbb8407c0 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -76,6 +76,7 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/crc32.h> /* For counting font checksums */
+#include <linux/uaccess.h>
#include <asm/fb.h>
#include <asm/irq.h>
@@ -3318,29 +3319,47 @@ void fbcon_get_requirement(struct fb_info *info,
}
}
-static int fbcon_event_notify(struct notifier_block *self,
- unsigned long action, void *data)
+int fbcon_set_con2fb_map_ioctl(void __user *argp)
{
- struct fb_event *event = data;
- struct fb_info *info = event->info;
- struct fb_con2fbmap *con2fb;
- int idx, ret = 0;
+ struct fb_con2fbmap con2fb;
+ int ret;
- switch(action) {
- case FB_EVENT_SET_CONSOLE_MAP:
- /* called with console lock held */
- con2fb = event->data;
- ret = set_con2fb_map(con2fb->console - 1,
- con2fb->framebuffer, 1);
- break;
- case FB_EVENT_GET_CONSOLE_MAP:
- con2fb = event->data;
- con2fb->framebuffer = con2fb_map[con2fb->console - 1];
- break;
+ if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
+ return -EFAULT;
+ if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
+ return -EINVAL;
+ if (con2fb.framebuffer >= FB_MAX)
+ return -EINVAL;
+ if (!registered_fb[con2fb.framebuffer])
+ request_module("fb%d", con2fb.framebuffer);
+ if (!registered_fb[con2fb.framebuffer]) {
+ return -EINVAL;
}
+
+ console_lock();
+ ret = set_con2fb_map(con2fb.console - 1,
+ con2fb.framebuffer, 1);
+ console_unlock();
+
return ret;
}
+int fbcon_get_con2fb_map_ioctl(void __user *argp)
+{
+ struct fb_con2fbmap con2fb;
+
+ if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
+ return -EFAULT;
+ if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
+ return -EINVAL;
+
+ console_lock();
+ con2fb.framebuffer = con2fb_map[con2fb.console - 1];
+ console_unlock();
+
+ return copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
+}
+
/*
* The console `switch' structure for the frame buffer based console
*/
@@ -3372,10 +3391,6 @@ static const struct consw fb_con = {
.con_debug_leave = fbcon_debug_leave,
};
-static struct notifier_block fbcon_event_notifier = {
- .notifier_call = fbcon_event_notify,
-};
-
static ssize_t store_rotate(struct device *device,
struct device_attribute *attr, const char *buf,
size_t count)
@@ -3648,7 +3663,6 @@ void __init fb_console_init(void)
int i;
console_lock();
- fb_register_client(&fbcon_event_notifier);
fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
"fbcon");
@@ -3684,7 +3698,6 @@ static void __exit fbcon_deinit_device(void)
void __exit fb_console_exit(void)
{
console_lock();
- fb_unregister_client(&fbcon_event_notifier);
fbcon_deinit_device();
device_destroy(fb_class, MKDEV(0, 0));
fbcon_exit();
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index dd1a708df1a7..64dd732021d8 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1092,10 +1092,8 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
struct fb_ops *fb;
struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix;
- struct fb_con2fbmap con2fb;
struct fb_cmap cmap_from;
struct fb_cmap_user cmap;
- struct fb_event event;
void __user *argp = (void __user *)arg;
long ret = 0;
@@ -1157,38 +1155,10 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
ret = -EINVAL;
break;
case FBIOGET_CON2FBMAP:
- if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
- return -EFAULT;
- if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
- return -EINVAL;
- con2fb.framebuffer = -1;
- event.data = &con2fb;
- lock_fb_info(info);
- event.info = info;
- fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
- unlock_fb_info(info);
- ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
+ ret = fbcon_get_con2fb_map_ioctl(argp);
break;
case FBIOPUT_CON2FBMAP:
- if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
- return -EFAULT;
- if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
- return -EINVAL;
- if (con2fb.framebuffer >= FB_MAX)
- return -EINVAL;
- if (!registered_fb[con2fb.framebuffer])
- request_module("fb%d", con2fb.framebuffer);
- if (!registered_fb[con2fb.framebuffer]) {
- ret = -EINVAL;
- break;
- }
- event.data = &con2fb;
- console_lock();
- lock_fb_info(info);
- event.info = info;
- ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, &event);
- unlock_fb_info(info);
- console_unlock();
+ ret = fbcon_set_con2fb_map_ioctl(argp);
break;
case FBIOBLANK:
console_lock();
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 25e4b885f5b3..303771264644 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -133,10 +133,6 @@ struct fb_cursor_user {
#define FB_EVENT_FB_UNREGISTERED 0x06
#endif
-/* CONSOLE-SPECIFIC: get console to framebuffer mapping */
-#define FB_EVENT_GET_CONSOLE_MAP 0x07
-/* CONSOLE-SPECIFIC: set console to framebuffer mapping */
-#define FB_EVENT_SET_CONSOLE_MAP 0x08
/* A display blank is requested */
#define FB_EVENT_BLANK 0x09
/* A hardware display blank early change occurred */
diff --git a/include/linux/fbcon.h b/include/linux/fbcon.h
index 69f900d289b2..ff5596dd30f8 100644
--- a/include/linux/fbcon.h
+++ b/include/linux/fbcon.h
@@ -17,6 +17,8 @@ void fbcon_get_requirement(struct fb_info *info,
void fbcon_fb_blanked(struct fb_info *info, int blank);
void fbcon_update_vcs(struct fb_info *info, bool all);
void fbcon_remap_all(struct fb_info *info);
+int fbcon_set_con2fb_map_ioctl(void __user *argp);
+int fbcon_get_con2fb_map_ioctl(void __user *argp);
#else
static inline void fb_console_init(void) {}
static inline void fb_console_exit(void) {}
@@ -33,6 +35,8 @@ static inline void fbcon_get_requirement(struct fb_info *info,
static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {}
static inline void fbcon_update_vcs(struct fb_info *info, bool all) {}
static inline void fbcon_remap_all(struct fb_info *info) {}
+static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
+static inline int fbcon_get_con2fb_map_ioctl(void __user *argp) { return 0; }
#endif
#endif /* _LINUX_FBCON_H */
--
2.20.1
next prev parent reply other threads:[~2019-05-24 8:54 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 8:53 [PATCH 00/33] fbcon notifier begone! Daniel Vetter
2019-05-24 8:53 ` [PATCH 01/33] dummycon: Sprinkle locking checks Daniel Vetter
2019-05-24 8:53 ` [PATCH 02/33] fbdev: locking check for fb_set_suspend Daniel Vetter
2019-05-24 8:53 ` [PATCH 03/33] vt: might_sleep() annotation for do_blank_screen Daniel Vetter
2019-05-24 8:53 ` [PATCH 04/33] vt: More locking checks Daniel Vetter
2019-05-27 7:08 ` Daniel Vetter
2019-05-27 7:22 ` Greg Kroah-Hartman
2019-05-24 8:53 ` [PATCH 05/33] fbdev/sa1100fb: Remove dead code Daniel Vetter
2019-05-24 8:53 ` [PATCH 06/33] fbdev/cyber2000: Remove struct display Daniel Vetter
2019-05-24 8:53 ` [PATCH 07/33] fbdev/aty128fb: Remove dead code Daniel Vetter
2019-05-24 8:53 ` [PATCH 08/33] fbcon: s/struct display/struct fbcon_display/ Daniel Vetter
2019-05-24 8:53 ` [PATCH 09/33] fbcon: Remove fbcon_has_exited Daniel Vetter
2019-05-25 15:38 ` Sam Ravnborg
2019-05-27 6:10 ` Daniel Vetter
2019-05-27 6:51 ` Sam Ravnborg
2019-05-24 8:53 ` [PATCH 10/33] fbcon: call fbcon_fb_(un)registered directly Daniel Vetter
2019-05-24 8:53 ` [PATCH 11/33] fbdev/sh_mobile: remove sh_mobile_lcdc_display_notify Daniel Vetter
2019-05-25 15:01 ` Sam Ravnborg
2019-05-27 6:13 ` Daniel Vetter
2019-05-27 6:52 ` Sam Ravnborg
2019-05-24 8:53 ` [PATCH 12/33] fbdev/omap: sysfs files can't disappear before the device is gone Daniel Vetter
2019-05-24 8:53 ` [PATCH 13/33] fbdev: " Daniel Vetter
2019-05-24 8:53 ` [PATCH 14/33] staging/olpc: lock_fb_info can't fail Daniel Vetter
2019-05-27 7:10 ` Daniel Vetter
2019-05-27 7:22 ` Greg KH
2019-05-24 8:53 ` [PATCH 15/33] fbdev/atyfb: " Daniel Vetter
2019-05-24 8:53 ` [PATCH 16/33] fbdev: lock_fb_info cannot fail Daniel Vetter
2019-05-24 8:53 ` [PATCH 17/33] fbcon: call fbcon_fb_bind directly Daniel Vetter
2019-05-24 8:53 ` [PATCH 18/33] fbdev: make unregister/unlink functions not fail Daniel Vetter
2019-05-24 8:53 ` [PATCH 19/33] fbdev: unify unlink_framebuffer paths Daniel Vetter
2019-05-24 8:53 ` [PATCH 20/33] fbdev/sh_mob: Remove fb notifier callback Daniel Vetter
2019-05-24 8:53 ` [PATCH 21/33] fbdev: directly call fbcon_suspended/resumed Daniel Vetter
2019-05-24 8:53 ` [PATCH 22/33] fbcon: Call fbcon_mode_deleted/new_modelist directly Daniel Vetter
2019-05-24 8:53 ` [PATCH 23/33] fbdev: Call fbcon_get_requirement directly Daniel Vetter
2019-05-24 8:53 ` [PATCH 24/33] Revert "backlight/fbcon: Add FB_EVENT_CONBLANK" Daniel Vetter
2019-05-24 13:14 ` Daniel Thompson
2019-05-24 15:28 ` Daniel Vetter
2019-05-27 10:59 ` Bartlomiej Zolnierkiewicz
2019-05-24 8:53 ` [PATCH 25/33] fbmem: pull fbcon_fb_blanked out of fb_blank Daniel Vetter
2019-05-25 17:00 ` Sam Ravnborg
2019-05-24 8:53 ` [PATCH 26/33] fbdev: remove FBINFO_MISC_USEREVENT around fb_blank Daniel Vetter
2019-05-24 8:53 ` [PATCH 27/33] fb: Flatten control flow in fb_set_var Daniel Vetter
2019-05-24 8:53 ` [PATCH 28/33] fbcon: replace FB_EVENT_MODE_CHANGE/_ALL with direct calls Daniel Vetter
2019-05-24 8:53 ` [PATCH 29/33] vgaswitcheroo: call fbcon_remap_all directly Daniel Vetter
2019-05-24 8:53 ` Daniel Vetter [this message]
2019-05-24 8:53 ` [PATCH 31/33] fbcon: Document what I learned about fbcon locking Daniel Vetter
2019-05-24 8:53 ` [PATCH 32/33] staging/olpc_dcon: Add drm conversion to TODO Daniel Vetter
2019-05-27 7:11 ` Daniel Vetter
2019-05-27 7:22 ` Greg KH
2019-05-24 8:53 ` [PATCH 33/33] backlight: simplify lcd notifier Daniel Vetter
2019-05-25 17:19 ` [PATCH 00/33] fbcon notifier begone! Sam Ravnborg
2019-05-27 7:17 ` Daniel Vetter
2019-05-27 11:56 ` Daniel Vetter
2019-05-28 9:02 [PATCH 00/33] fbcon notifier begone v3! Daniel Vetter
2019-05-28 9:03 ` [PATCH 30/33] fbcon: Call con2fb_map functions directly Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190524085354.27411-31-daniel.vetter@ffwll.ch \
--to=daniel.vetter@ffwll.ch \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=mpatocka@redhat.com \
--cc=peda@axentia.se \
--cc=ysxie@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).