From: "Antonino A. Daplas" <adaplas@gmail.com>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Dave Airlie <airlied@linux.ie>,
Jakob Bornecrantz <wallbraker@gmail.com>,
linux-fbdev-devel@lists.sourceforge.net
Subject: Re: Console unregistration questions
Date: Wed, 25 Apr 2007 09:17:13 +0800 [thread overview]
Message-ID: <1177463833.4829.20.camel@daplas> (raw)
In-Reply-To: <200704241646.34556.jbarnes@virtuousgeek.org>
[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]
On Tue, 2007-04-24 at 16:46 -0700, Jesse Barnes wrote:
> On Tuesday, April 24, 2007, Antonino A. Daplas wrote:
> > > > Also, shouldn't callers of
> > > > unregister_con_driver be checking return values? That would have
> > > > made this bug a lot easier to find at least. :)
> >
> > Replying to myself:
> >
> > At this point, if unregister_con_driver() fails, it is too late for
> > fbcon, the best thing to do is issue a BUG().
>
> I guess there's no way to propagate the error back to
> unregister_framebuffer? If we did, then it could return -EBUSY or
> something, keeping the module loaded instead of unsafely allowing it to be
> removed...
>
> > However, I'll add extra code to unregister_framebuffer() that will check
> > if it's safe for the driver to unload. The drivers may then choose to
> > check it or not.
>
> Sounds good.
>
Here's a test patch. Basically, it checks if the driver is still mapped
to the console, and if it is, unregister_framebuffer() will exit
immediately. As mentioned, it's untested, so let me know if there are
problems.
Note, the driver must also do its part, by checking if the driver is
opened by something in userspace.
Tony
[-- Attachment #2: safe_unregister.diff --]
[-- Type: text/x-patch, Size: 1340 bytes --]
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 34ec0ef..f424adb 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -3100,6 +3100,8 @@ static int fbcon_event_notify(struct not
case FB_EVENT_NEW_MODELIST:
fbcon_new_modelist(info);
break;
+ case FB_EVENT_FB_UNREGISTER_SAFE:
+ ret = search_fb_in_map(info->node);
}
done:
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index cd14079..8e878e6 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1362,6 +1362,10 @@ unregister_framebuffer(struct fb_info *f
if (!registered_fb[i])
return -EINVAL;
+ event.info = fb_info;
+ if (fb_notifier_call_chain(FB_EVENT_FB_UNREGISTER_SAFE, &event))
+ return -EINVAL;
+
if (fb_info->pixmap.addr &&
(fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
kfree(fb_info->pixmap.addr);
diff --git a/include/linux/fb.h b/include/linux/fb.h
index ecb8bc6..e955865 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -527,6 +527,8 @@ #define FB_EVENT_NEW_MODELIST
#define FB_EVENT_MODE_CHANGE_ALL 0x0B
/* A software display blank change occured */
#define FB_EVENT_CONBLANK 0x0C
+/* Check if it's safe to unregister */
+#define FB_EVENT_FB_UNREGISTER_SAFE 0x0D
struct fb_event {
struct fb_info *info;
[-- Attachment #3: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #4: Type: text/plain, Size: 182 bytes --]
_______________________________________________
Linux-fbdev-devel mailing list
Linux-fbdev-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
next prev parent reply other threads:[~2007-04-25 1:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-24 21:59 Console unregistration questions Jesse Barnes
2007-04-24 23:19 ` Antonino A. Daplas
2007-04-24 23:42 ` Antonino A. Daplas
2007-04-24 23:46 ` Jesse Barnes
2007-04-25 0:07 ` Antonino A. Daplas
2007-04-25 1:17 ` Antonino A. Daplas [this message]
2007-04-26 17:00 ` Jesse Barnes
2007-04-27 1:30 ` Jesse Barnes
2007-04-27 6:10 ` Antonino A. Daplas
2007-04-27 15:14 ` Jesse Barnes
2007-04-27 16:10 ` Antonino A. Daplas
2007-04-24 23:42 ` Jesse Barnes
2007-04-25 0:04 ` Antonino A. Daplas
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=1177463833.4829.20.camel@daplas \
--to=adaplas@gmail.com \
--cc=airlied@linux.ie \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=wallbraker@gmail.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).