PV framebuffer
PATCH 1/2 PV framebuffer
PV framebuffer frontend. Derived from
http://www.cs.utexas.edu/users/aliguori/vfb-20060124.bundle
Extensive changes based on feedback from xen-devel.
--- arch/i386/kernel/setup-xen.c | 5 arch/ia64/kernel/setup.c | 4 arch/x86_64/kernel/setup-xen.c | 7 drivers/char/tty_io.c | 6 drivers/xen/Kconfig | 23 + drivers/xen/Makefile | 2 drivers/xen/console/console.c | 56 +++ drivers/xen/xenfb/Makefile | 1 drivers/xen/xenfb/xenfb.c | 638 ++++++++++++++++++++++++++++++++++++++ drivers/xen/xenkbd/Makefile | 1 drivers/xen/xenkbd/xenkbd.c | 271 ++++++++++++++++ include/xen/interface/io/xenfb.h | 116 ++++++ include/xen/interface/io/xenkbd.h | 108 ++++++ 13 files changed, 1221 insertions(+), 17 deletions(-)
arch/i386/kernel/setup-xen.c +3 -2
@@ -1850,8 +1850,9 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif } }
arch/ia64/kernel/setup.c +2 -2
@@ -550,9 +550,9 @@ setup_arch (char **cmdline_p) xen_start_info->nr_pages, xen_start_info->flags);if (!is_initial_xendomain ()) { -extern int console_use_vt; +#if !defined(CONFIG_VT ) || !defined(CONFIG_DUMMY_CONSOLE ) conswitchp =NULL ; - console_use_vt =0 ; +#endif } }#endif
arch/x86_64/kernel/setup-xen.c +4 -3
@@ -970,9 +970,10 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; - } +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif + } }#else /* CONFIG_XEN */
drivers/char/tty_io.c +1 -5
@@ -132,8 +132,6 @@ LIST_HEAD(tty_drivers); /* linked listvt.c for deeply disgusting hack reasons */ DECLARE_MUTEX (tty_sem); -int console_use_vt =1 ; -#ifdef CONFIG_UNIX98_PTYS extern struct tty_driver *ptm_driver;/* Unix98 pty masters; for /dev/ptmx */ extern int pty_limit;/* Config limit on Unix98 ptys */
@@ -2056,7 +2054,7 @@ retry_open: goto got_driver; }#ifdef CONFIG_VT -if (console_use_vt && (device ==MKDEV (TTY_MAJOR ,0 ))) { +if (device ==MKDEV (TTY_MAJOR ,0 )) {extern struct tty_driver *console_driver; driver = console_driver; index = fg_console;
@@ -3247,8 +3245,6 @@ static int __init tty_init(void)#endif #ifdef CONFIG_VT -if (!console_use_vt) - goto out_vt;cdev_init (&vc0_cdev, &console_fops);if (cdev_add (&vc0_cdev,MKDEV (TTY_MAJOR ,0 ),1 ) ||register_chrdev_region (MKDEV (TTY_MAJOR ,0 ),1 ,"/dev/vc/0" ) <0 )
drivers/xen/Kconfig +23 -0
@@ -172,6 +172,29 @@ config XEN_NETDEV_FRONTEND dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_FRAMEBUFFER + tristate "Framebuffer-device frontend driver" + depends on XEN && FB + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + default y + help + The framebuffer-device frontend drivers allows the kernel to create a + virtual framebuffer. This framebuffer can be viewed in another + domain. Unless this domain has access to a real video card, you + probably want to say Y here. + +config XEN_KEYBOARD + tristate "Keyboard-device frontend driver" + depends on XEN + default y + help + The keyboard-device frontend driver allows the kernel to create a + virtual keyboard. This keyboard can then be driven by another + domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably + want to say Y here. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default y
drivers/xen/Makefile +2 -0
@@ -15,3 +15,5 @@ obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blk obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/ obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/ obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/ +obj-$(CONFIG_XEN_FRAMEBUFFER) += xenfb/ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd/
drivers/xen/console/console.c +51 -5
121 lines not on this page · raw message
drivers/xen/xenfb/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_FRAMEBUFFER) := xenfb.o
drivers/xen/xenfb/xenfb.c +638 -0
638 lines not on this page · raw message
drivers/xen/xenkbd/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd.o
drivers/xen/xenkbd/xenkbd.c +271 -0
271 lines not on this page · raw message
include/xen/interface/io/xenfb.h +116 -0
116 lines not on this page · raw message
include/xen/interface/io/xenkbd.h +108 -0
108 lines not on this page · raw message
Quoted 6 lines
diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/console/console.clinux-2.6.16.29-xen-vfb/drivers/xen/console/console.cdrivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +0
-0@@ -195,12 +210,23 @@ static int __init xen_console_init(void) } else { if (!xen_start_info->console.domU.evtchn)
drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 static int __init xen_console_init(void) · line 219
Quoted 10 lines
drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +7
-2goto out; - if (xc_mode == XC_DEFAULT) - xc_mode = XC_TTY; + if (xc_mode == XC_DEFAULT) { +#ifdef CONFIG_XEN_FRAMEBUFFER + xc_mode = XC_XVC; +#else + xc_mode = XC_TTY; +#endif + }
This hunk is changing the default behaviour of xencons in domU from registering as tty{0...} to registering as xvc{0...}, yes? That's going to confuse a lot of people with existing domUs which have gettys etc. set up on /dev/ttyX but not /dev/xvcX.
Or am I confused again?
Quoted 18 lines
drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +0
-0kcons_info.write = kcons_write; } switch (xc_mode) {diff -rupN -x '*.orig' linux-2.6.16.29-xen/drivers/xen/Kconfig linux-2.6.16.29-xen-vfb/drivers/xen/Kconfig
drivers/xen/Kconfig +6
-0@@ -172,3 +172,19 @@ config XEN_NETDEV_FRONTEND dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_FRAMEBUFFER + tristate "Framebuffer-device frontend driver" + depends on XEN && FB + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT
drivers/xen/Kconfig config XEN_NETDEV_FRONTEND · line 190
Quoted 10 lines
drivers/xen/Kconfig +10
-0+ default y + help + The framebuffer-device frontend drivers allows the kernel to create a + virtual framebuffer. This framebuffer can be viewed in another + domain. Unless this domain has access to a real video card, you + probably want to say Y here. + +config XEN_KEYBOARD + tristate "Keyboard-device frontend driver" + depends on XEN
Does this want to depend on XEN_FRAMEBUFFER and INPUT?
Quoted 20 lines
drivers/xen/Kconfig +7
-0+ default y + help + The keyboard-device frontend driver allows the kernel to create a + virtual keyboard. This keyboard can then be driven by another + domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably + want to say Y here. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default ydiff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/console/console.clinux-2.6.16.29-xen-vfb/drivers/xen/console/console.cdrivers/xen/console/console.c +3
-0@@ -680,3 +712,17 @@ static int __init xencons_init(void)printk ("Xen virtual console successfully installed as %s%d\n" ,DRV (xencons_driver)->name, xc_num); +/* Don't need to check about graphical fb for domain 0 */ +if (is_initial_xendomain ()) +return 0 ;
drivers/xen/console/console.c static int __init xencons_init(void) · line 727
Quoted 10 lines
drivers/xen/console/console.c +10
-0+ + rc =0 ; +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &rc) <0 ) +printk (KERN_ERR "Unable to read console/use_graphics\n" ); +if (rc ==0 ) { +/* FIXME: this is ugly */ +unregister_console (&kcons_info); + kcons_info.flags |=CON_CONSDEV ; +register_console (&kcons_info); + }
I'm still not entirely sure I understand why this bit is necessary.
From talking to [email protected] last time:
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Also, why do you need to set
CON_CONSDEVat all?Otherwise, you don't get kernel console messages.
Why not? None of the other console drivers seem to need to set it explicitly, and it seems like it would break setting console=blah on the kernel command line.
Nothing else sets it explicitly because it happens implicitly in the console registration code for the first thing registered with
register_console(). Alternately, if you have a console=, thenregister_consoleensures that your console device hasCON_CONSDEVset.kernel/printk.cif you want to read all the gory details
Quoted 4 lines
The intent of this code seems to be to make sure that
CON_CONSDEVis definitely set on xenconsole ifuse_graphicsis not set, yes? But as far as I can see, ifuse_graphicsis not set, xenfb should never callregister_console(), and so this is all redundant.
I'm still just as unenlightened as I was then. Plus, xen_console_init should be called before any of the pvfb stuff anyway, since it's a console_initcall and pvfb starts from a module_init, so it's doubly redundant.
Quoted 10 lines
return 0;
}diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/xenfb/xenfb.clinux-2.6.16.29-xen-vfb/drivers/xen/xenfb/xenfb.cdrivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +3
-0+static int __devinit xenfb_probe(struct xenbus_device *dev, + const struct xenbus_device_id *id) +{
...
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 8 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +8
-0+ ret = fb_alloc_cmap(&fb_info->cmap, 256, 0); + if (ret < 0) { + framebuffer_release(fb_info); + xenbus_dev_fatal(dev, ret, "fb_alloc_cmap"); + goto error; + } + + /* FIXME should this be delayed until backend XenbusStateConnected? */
I would, but I'm not sure it matters too much. You have a potentially slightly confusing situation where someone starts using the framebuffer before the backend connects, so the backend has to be able to handle there being events on the ring when it starts, but I think it probably works as it is.
Quoted 4 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +4
-0+ ret = register_framebuffer(fb_info); + if (ret) { + fb_dealloc_cmap(&info->fb_info->cmap); + framebuffer_release(fb_info);
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 10 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +10
-0+ xenbus_dev_fatal(dev, ret, "register_framebuffer"); + goto error; + } + info->fb_info = fb_info; + + info->kthread = kthread_run(xenfb_thread, info, "xenfb thread"); + if (IS_ERR(info->kthread)) { + ret = PTR_ERR(info->kthread); + xenbus_dev_fatal(dev, ret, "register_framebuffer"); + goto error;
goto error will end up calling xenfb_remove, which will notice that info->kthread is non-NULL and try to kthread_stop it. That strikes me as a bad idea.
...
Quoted 1 line
+static int
__devexitxenfb_remove(struct xenbus_device *dev)
This gets called from some error paths even when the driver is remaining loaded. Is __devexit safe? I'm thinking particularly of the case where the kernel is compiled without module unloading and discards exit text segments.
Quoted 18 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +18
-0+{ + struct xenfb_info *info = dev->dev.driver_data; + + del_timer(&info->refresh); + if (info->kthread) + kthread_stop(info->kthread); + if (info->irq >= 0) + unbind_from_irqhandler(info->irq, info); + if (info->fb_info) { + unregister_framebuffer(info->fb_info); + fb_dealloc_cmap(&info->fb_info->cmap); + framebuffer_release(info->fb_info); + } + free_page((unsigned long)info->page); + vfree(info->mfns); + kfree(info->pages); + vfree(info->fb); + kfree(info);
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 10 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +10
-0+ + return 0; +} + +static struct xenbus_driver xenfb = { + .name = "vfb", + .owner = THIS_MODULE, + .ids = xenfb_ids, + .probe = xenfb_probe, + .remove = xenfb_remove,
I think this wants to be __devexit_p.
Quoted 9 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +9
-0+ /* TODO .resume = xenfb_resume, */ + .otherend_changed = xenfb_backend_changed, +}; + +static int __init xenfb_init(void) +{ + int ret; + + if (!is_running_on_xen())
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 10 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +10
-0+ return -ENODEV; + + /* Nothing to do if running in dom0. */ + if (is_initial_xendomain()) + return -ENODEV; + /* if we're not set up to use graphics mode, then don't initialize */ + if (xenbus_scanf(XBT_NIL, "console", "use_graphics", "%d", &ret) < 0) + return -ENODEV; + if (ret == 0) + return -ENODEV;
Not sure about this. It seems to me like it might be useful to sometimes have domains which have a PVFB but still use xencons for kernel printks etc. Perhaps I'm just confused.
Quoted 20 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +13
-0+ + return xenbus_register_frontend(&xenfb); +} + +static void __exit xenfb_cleanup(void) +{ + return xenbus_unregister_driver(&xenfb); +} + +module_init(xenfb_init); +module_exit(xenfb_cleanup); + +MODULE_LICENSE("GPL");diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/xenkbd/xenkbd.clinux-2.6.16.29-xen-vfb/drivers/xen/xenkbd/xenkbd.cdrivers/xen/xenkbd/xenkbd.c +3
-0@@ -0,0 +1,123 @@ +int __devinit xenkbd_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{
...
drivers/xen/xenkbd/xenkbd.c line 112
Quoted 5 lines
drivers/xen/xenkbd/xenkbd.c +5
-0+ input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); + input_dev->keybit[LONG (BTN_MOUSE )] + =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); +/* FIXME more buttons? */ + input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );
Do you need to set some bits in absbit, as well, since you can generate absolute coordinate messages?
drivers/xen/xenkbd/xenkbd.c line 123
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +6
-0+ input_dev->name ="Xen Virtual Keyboard/Mouse" ; + +input_set_abs_params (input_dev,ABS_X ,0 ,XENFB_WIDTH ,0 ,0 ); +input_set_abs_params (input_dev,ABS_Y ,0 ,XENFB_HEIGHT ,0 ,0 ); + +/* FIXME should this be delayed until backend XenbusStateConnected? */
Again, I would move it if I were doing this, but it makes even less difference here than it did before.
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c +7
-0+ ret =register_framebuffer (fb_info); +if (ret) { +fb_dealloc_cmap (&info->fb_info->cmap); +framebuffer_release (fb_info); +xenbus_dev_fatal (dev, ret,"register_framebuffer" ); + goto error; + }
...
Quoted 1 line
+static int
__devexitxenkbd_remove(struct xenbus_device *dev)
Again, not convinced __devexit is entirely valid here.
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c +7
-0+{ +struct xenkbd_info *info = dev->dev.driver_data; + +if (info->irq >=0 ) +unbind_from_irqhandler (info->irq, info); +input_unregister_device (info->dev); +free_page ((unsigned long )info->page);
drivers/xen/xenkbd/xenkbd.c line 238
Quoted 10 lines
drivers/xen/xenkbd/xenkbd.c +9
-0+kfree (info); +return 0 ; +} +static struct xenbus_driver xenkbd = { + .name ="vkbd" , + .owner =THIS_MODULE , + .ids = xenkbd_ids, + .probe = xenkbd_probe, + .remove = xenkbd_remove,
Again, might want to be __devexit_p.
Quoted 9 lines
drivers/xen/xenkbd/xenkbd.c +9
-0+//.resume = xenkbd_resume, + .otherend_changed = xenkbd_backend_changed, +}; + +static int __init xenkbd_init (void ) +{ +int ret; + +if (!is_running_on_xen ())
drivers/xen/xenkbd/xenkbd.c line 257
Quoted 10 lines
drivers/xen/xenkbd/xenkbd.c +10
-0+return -ENODEV ; + +/* Nothing to do if running in dom0. */ +if (is_initial_xendomain ()) +return -ENODEV ; +/* if we're not set up to use graphics mode, then don't initialize */ +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &ret) <0 ) +return -ENODEV ; +if (ret ==0 ) +return -ENODEV ;
This test obviously wants to be kept in sync with the corresponding test in xenfb_init, so the same comments apply here as there.
include/xen/interface/io/xenfb.h
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +2
-0+return xenbus_register_frontend (&xenkbd); +}diff -rupN -x '*.orig'
linux-2.6.16.29-xen/include/xen/interface/io/xenfb.hlinux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.hinclude/xen/interface/io/xenfb.h +0
-0
I think this really wants to be in xen/include/public/io, but I'd guess this is just an artifact of the diff.
Quoted 7 lines
include/xen/interface/io/xenfb.h +7
-0+struct xenfb_update +{ +__u8 type;/* XENFB_TYPE_UPDATE */ +__s32 x;/* source x */ +__s32 y;/* source y */ +__s32 width;/* rect width */ +__s32 height;/* rect height */
include/xen/interface/io/xenfb.h line 48
Quoted 10 lines
include/xen/interface/io/xenfb.h +10
-0+}; + +#define XENFB_OUT_EVENT_SIZE 40 + +union xenfb_out_event +{ +__u8 type; +struct xenfb_update update; +char pad[XENFB_OUT_EVENT_SIZE ]; +};
I still think you'd be better off doing tagged unions the usual way, but your funeral.
Quoted 4 lines
+/*
+ * Wart: xenkbd needs to know resolution. Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */
Why does xenkbd need to know the resolution? Do you mean xenfb?
As far as I can see, these only get used in xenfb.c, so the #defines could go there rather than in the IO description header.
include/xen/interface/io/xenfb.h line 116
Quoted 7 lines
include/xen/interface/io/xenfb.h +7
-0+#ifdef __KERNEL__ +#define XENFB_WIDTH 800 +#define XENFB_HEIGHT 600 +#define XENFB_DEPTH 32 +#endif + +#endif
Steven.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · Steven Smith
drivers/xen/console/console.c static int __init xen_console_init(void) · line 219
Quoted 6 lines
drivers/xen/console/console.c +6
-0+#ifdef CONFIG_XEN_FRAMEBUFFER + xc_mode =XC_XVC ; +#else + xc_mode =XC_TTY ; +#endif + }This hunk is changing the default behaviour of xencons in domU from registering as tty{0...} to registering as xvc{0...}, yes? That's going to confuse a lot of people with existing domUs which have gettys etc. set up on
/dev/ttyXbut not/dev/xvcX.
We're waiting to hear from lanana before switching to xvc. I re-submitted the allocation request two weeks ago (31st October). I haven't heard anything yet. I suppose since static device nodes in /dev are rare these days (since everyone moved to udev) we can just squat on some device number for the time being, or settle for requesting a dynamic one at boot time and require use of udev for anyone who cares about the device node. We already settled for that with /dev/xen/evtchn, for example.
-- Keir
[A bit of context restored]
Quoted 2 lines · Keir Fraser
On 12/11/06 2:20 pm, "Steven Smith" <[email protected]> wrote:
diff -rupN -x '*.orig' linux-2.6.16.29-xen/drivers/xen/console/console.c linux-2.6.16.29-xen-vfb/drivers/xen/console/console.c
--- linux-2.6.16.29-xen/drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200
+++ linux-2.6.16.29-xen-vfb/drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100
@@ -195,12 +210,23 @@ static int __init xen_console_init(void)
} else {
if (!xen_start_info->console.domU.evtchn)
goto out;
- if (xc_mode == XC_DEFAULT)
- xc_mode = XC_TTY;Quoted 11 lines
Quoted 10 lines
drivers/xen/console/console.c static int __init xen_console_init(void) · line 219
Quoted 6 lines
drivers/xen/console/console.c +6
-0+#ifdef CONFIG_XEN_FRAMEBUFFER + xc_mode =XC_XVC ; +#else + xc_mode =XC_TTY ; +#endif + }This hunk is changing the default behaviour of xencons in domU from registering as tty{0...} to registering as xvc{0...}, yes? That's going to confuse a lot of people with existing domUs which have gettys etc. set up on
/dev/ttyXbut not/dev/xvcX.
Quoted 7 lines
We're waiting to hear from lanana before switching to xvc. I re-submitted the allocation request two weeks ago (31st October). I haven't heard anything yet. I suppose since static device nodes in /dev are rare these days (since everyone moved to udev) we can just squat on some device number for the time being, or settle for requesting a dynamic one at boot time and require use of udev for anyone who cares about the device node. We already settled for that with
/dev/xen/evtchn, for example.
What do you want me to do here for the short term? Drop the patch hunk and let you sort it out?
Please mind the discussion we had some time ago, most relevant message appended.
From: Steven Smith <[email protected]>
Subject: Re: [Xen-devel] [PATCH] Paravirt framebuffer use xvc as console [4/5]
To: Jeremy Katz <[email protected]>
Cc: xen-devel <[email protected]>,
Markus Armbruster <[email protected]>, [email protected], Amos Waterland <[email protected]>
Date: Wed, 6 Sep 2006 22:17:13 +0100
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
This is the patch from Amos Waterland for the xenconsole to use
/dev/xvc0instead of taking over ttys. I've fixed a few places which needed to check for XVC mode in addition to serial mode. Also, until LANANA responds with an official minor, I've adjusted it to use char 250/187 (in the experimental range) as opposed to 204/187.(Should be identical to this patch from last time)
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Does this have anything to do with the virtual framebuffer work, or does it stand alone?
It stands alone, but without it, the framebuffer bits get a little confusing to actually try to have used as the console.
What goes wrong?
xenconsole takes over ttys and although you can see the framebuffer with the penguin and X will start, you can't actually use the framebuffer as a console :-)
Ack, got it now. Forgive me for being a little slow.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/xen/console/console.c static int __init xen_console_init(void) · line 212
Quoted 6 lines
drivers/xen/console/console.c +1
-1@@ -194,11 +209,17 @@ static int __init xen_console_init(void) kcons_info.write = kcons_write_dom0; }else {if (xc_mode ==XC_DEFAULT ) - xc_mode =XC_TTY ; + xc_mode =XC_XVC ;Not convinced we want to change the default until a little while after the rest of the patch gets merged.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The default *HAS* to be changed -- otherwise, the xvc console tries to take over ttys (which is really really really wrong in the guest)
So why have we survived this far without it? If
XC_TTYis completely broken, why not remove it completely?We've survived this far because there isn't anything else which is trying to use the console and this hack let people pretend they had multiple vcs[1].
Perhaps make this part #ifdef on CONFIG_XENFB at first? It'll be easier to merge if it obviously doesn't break any existing setup.
Steven.
Quoted 10 lines · Markus Armbruster
Quoted 7 lines
We're waiting to hear from lanana before switching to xvc. I re-submitted the allocation request two weeks ago (31st October). I haven't heard anything yet. I suppose since static device nodes in /dev are rare these days (since everyone moved to udev) we can just squat on some device number for the time being, or settle for requesting a dynamic one at boot time and require use of udev for anyone who cares about the device node. We already settled for that with
/dev/xen/evtchn, for example.What do you want me to do here for the short term? Drop the patch hunk and let you sort it out?
It doesn't seem to have much to do with the paravirt fb patch, so probably it should be dropped.
-- Keir
Quoted 21 lines · Steven Smith
Quoted 6 lines
diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/console/console.clinux-2.6.16.29-xen-vfb/drivers/xen/console/console.cdrivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +0
-0@@ -195,12 +210,23 @@ static int __init xen_console_init(void) } else { if (!xen_start_info->console.domU.evtchn)drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 static int __init xen_console_init(void) · line 219
Quoted 10 lines
drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +7
-2goto out; - if (xc_mode == XC_DEFAULT) - xc_mode = XC_TTY; + if (xc_mode == XC_DEFAULT) { +#ifdef CONFIG_XEN_FRAMEBUFFER + xc_mode = XC_XVC; +#else + xc_mode = XC_TTY; +#endif + }This hunk is changing the default behaviour of xencons in domU from registering as tty{0...} to registering as xvc{0...}, yes? That's going to confuse a lot of people with existing domUs which have gettys etc. set up on
/dev/ttyXbut not/dev/xvcX.
Quoted 1 line
Or am I confused again?
Already discussed elsewhere.
Quoted 21 lines
Quoted 21 lines
drivers/xen/console/console.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/console/console.c 2006-09-29 16:11:51.000000000 +0200 +0
-0kcons_info.write = kcons_write; } switch (xc_mode) {diff -rupN -x '*.orig' linux-2.6.16.29-xen/drivers/xen/Kconfig linux-2.6.16.29-xen-vfb/drivers/xen/Kconfig
drivers/xen/Kconfig +9
-0@@ -172,3 +172,19 @@ config XEN_NETDEV_FRONTEND dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_FRAMEBUFFER + tristate "Framebuffer-device frontend driver" + depends on XEN && FB + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + default y + help + The framebuffer-device frontend drivers allows the kernel to create a
Quoted 8 lines
drivers/xen/Kconfig config XEN_NETDEV_FRONTEND · line 190
Quoted 7 lines
drivers/xen/Kconfig +7
-0+ virtual framebuffer. This framebuffer can be viewed in another + domain. Unless this domain has access to a real video card, you + probably want to say Y here. + +config XEN_KEYBOARD + tristate "Keyboard-device frontend driver" + depends on XENDoes this want to depend on
XEN_FRAMEBUFFERand INPUT?
XEN_FRAMEBUFFER: yes. Jeremy fixed that, but I mismerged.
INPUT: I missed that.
Quoted 50 lines
Quoted 20 lines
drivers/xen/Kconfig +7
-0+ default y + help + The keyboard-device frontend driver allows the kernel to create a + virtual keyboard. This keyboard can then be driven by another + domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably + want to say Y here. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default ydiff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/console/console.clinux-2.6.16.29-xen-vfb/drivers/xen/console/console.cdrivers/xen/console/console.c +3
-0@@ -680,3 +712,17 @@ static int __init xencons_init(void)printk ("Xen virtual console successfully installed as %s%d\n" ,DRV (xencons_driver)->name, xc_num); +/* Don't need to check about graphical fb for domain 0 */ +if (is_initial_xendomain ()) +return 0 ;drivers/xen/console/console.c static int __init xencons_init(void) · line 727
Quoted 10 lines
drivers/xen/console/console.c +10
-0+ + rc =0 ; +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &rc) <0 ) +printk (KERN_ERR "Unable to read console/use_graphics\n" ); +if (rc ==0 ) { +/* FIXME: this is ugly */ +unregister_console (&kcons_info); + kcons_info.flags |=CON_CONSDEV ; +register_console (&kcons_info); + }I'm still not entirely sure I understand why this bit is necessary.
From talking to [email protected] last time:
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Also, why do you need to set
CON_CONSDEVat all?Otherwise, you don't get kernel console messages.
Why not? None of the other console drivers seem to need to set it explicitly, and it seems like it would break setting console=blah on the kernel command line.
Nothing else sets it explicitly because it happens implicitly in the console registration code for the first thing registered with
register_console(). Alternately, if you have a console=, thenregister_consoleensures that your console device hasCON_CONSDEVset.kernel/printk.cif you want to read all the gory detailsQuoted 4 lines
The intent of this code seems to be to make sure that
CON_CONSDEVis definitely set on xenconsole ifuse_graphicsis not set, yes? But as far as I can see, ifuse_graphicsis not set, xenfb should never callregister_console(), and so this is all redundant.
Quoted 4 lines
I'm still just as unenlightened as I was then. Plus,
xen_console_initshould be called before any of the pvfb stuff anyway, since it's aconsole_initcalland pvfb starts from amodule_init, so it's doubly redundant.
Jeremy, could you elaborate?
Quoted 11 lines
Quoted 10 lines
return 0;
}diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/xenfb/xenfb.clinux-2.6.16.29-xen-vfb/drivers/xen/xenfb/xenfb.cdrivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +3
-0+static int __devinit xenfb_probe(struct xenbus_device *dev, + const struct xenbus_device_id *id) +{...
Quoted 13 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 8 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +8
-0+ ret = fb_alloc_cmap(&fb_info->cmap, 256, 0); + if (ret < 0) { + framebuffer_release(fb_info); + xenbus_dev_fatal(dev, ret, "fb_alloc_cmap"); + goto error; + } + + /* FIXME should this be delayed until backend XenbusStateConnected? */I would, but I'm not sure it matters too much. You have a potentially slightly confusing situation where someone starts using the framebuffer before the backend connects, so the backend has to be able to handle there being events on the ring when it starts, but I think it probably works as it is.
Yes, it works.
I might move it eventually just for cleanliness.
Quoted 10 lines
Quoted 10 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +10
-0+ ret = register_framebuffer(fb_info); + if (ret) { + fb_dealloc_cmap(&info->fb_info->cmap); + framebuffer_release(fb_info); + xenbus_dev_fatal(dev, ret, "register_framebuffer"); + goto error; + } + info->fb_info = fb_info; + + info->kthread = kthread_run(xenfb_thread, info, "xenfb thread");
Quoted 8 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 4 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +4
-0+ if (IS_ERR(info->kthread)) { + ret = PTR_ERR(info->kthread); + xenbus_dev_fatal(dev, ret, "register_framebuffer"); + goto error;goto error will end up calling
xenfb_remove, which will notice thatinfo->kthreadis non-NULL and try tokthread_stopit. That strikes me as a bad idea.
...
Oops. Thanks for catching.
Quoted 5 lines
Quoted 1 line
+static int
__devexitxenfb_remove(struct xenbus_device *dev)This gets called from some error paths even when the driver is remaining loaded. Is
__devexitsafe? I'm thinking particularly of the case where the kernel is compiled without module unloading and discards exit text segments.
Insufficient understanding of __devexit on my part. Fixing.
Quoted 21 lines
Quoted 21 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +21
-0+{ + struct xenfb_info *info = dev->dev.driver_data; + + del_timer(&info->refresh); + if (info->kthread) + kthread_stop(info->kthread); + if (info->irq >= 0) + unbind_from_irqhandler(info->irq, info); + if (info->fb_info) { + unregister_framebuffer(info->fb_info); + fb_dealloc_cmap(&info->fb_info->cmap); + framebuffer_release(info->fb_info); + } + free_page((unsigned long)info->page); + vfree(info->mfns); + kfree(info->pages); + vfree(info->fb); + kfree(info); + + return 0; +}
Quoted 8 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 7 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +7
-0+ +static struct xenbus_driver xenfb = { + .name = "vfb", + .owner = THIS_MODULE, + .ids = xenfb_ids, + .probe = xenfb_probe, + .remove = xenfb_remove,I think this wants to be
__devexit_p.
Only if xenfb is __devexit, right?
Quoted 14 lines
Quoted 14 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +14
-0+ /* TODO .resume = xenfb_resume, */ + .otherend_changed = xenfb_backend_changed, +}; + +static int __init xenfb_init(void) +{ + int ret; + + if (!is_running_on_xen()) + return -ENODEV; + + /* Nothing to do if running in dom0. */ + if (is_initial_xendomain()) + return -ENODEV;
Quoted 8 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100
Quoted 5 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +5
-0+ /* if we're not set up to use graphics mode, then don't initialize */ + if (xenbus_scanf(XBT_NIL, "console", "use_graphics", "%d", &ret) < 0) + return -ENODEV; + if (ret == 0) + return -ENODEV;Not sure about this. It seems to me like it might be useful to sometimes have domains which have a PVFB but still use xencons for kernel printks etc. Perhaps I'm just confused.
I guess you're right.
Quoted 21 lines
Quoted 20 lines
drivers/xen/xenfb/xenfb.c 2006-11-10 09:43:37.000000000 +0100 renamed from drivers/xen/xenfb/xenfb.c 1970-01-01 01:00:00.000000000 +0100 +13
-0+ + return xenbus_register_frontend(&xenfb); +} + +static void __exit xenfb_cleanup(void) +{ + return xenbus_unregister_driver(&xenfb); +} + +module_init(xenfb_init); +module_exit(xenfb_cleanup); + +MODULE_LICENSE("GPL");diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/xenkbd/xenkbd.clinux-2.6.16.29-xen-vfb/drivers/xen/xenkbd/xenkbd.cdrivers/xen/xenkbd/xenkbd.c +3
-0@@ -0,0 +1,123 @@ +int __devinit xenkbd_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{...
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c line 112
Quoted 5 lines
drivers/xen/xenkbd/xenkbd.c +5
-0+ input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); + input_dev->keybit[LONG (BTN_MOUSE )] + =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); +/* FIXME more buttons? */ + input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );Do you need to set some bits in absbit, as well, since you can generate absolute coordinate messages?
We missed that. Curiously, everything seems to work all the same (as tested with evdev). Apparently, no consumer actually tests the bits correctly. Fixing anyway.
Quoted 8 lines
drivers/xen/xenkbd/xenkbd.c line 123
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +6
-0+ input_dev->name ="Xen Virtual Keyboard/Mouse" ; + +input_set_abs_params (input_dev,ABS_X ,0 ,XENFB_WIDTH ,0 ,0 ); +input_set_abs_params (input_dev,ABS_Y ,0 ,XENFB_HEIGHT ,0 ,0 ); + +/* FIXME should this be delayed until backend XenbusStateConnected? */ Again, I would move it if I were doing this, but it makes even less difference here than it did before.
Understood.
Quoted 11 lines
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c +7
-0+ ret =register_framebuffer (fb_info); +if (ret) { +fb_dealloc_cmap (&info->fb_info->cmap); +framebuffer_release (fb_info); +xenbus_dev_fatal (dev, ret,"register_framebuffer" ); + goto error; + }...
Quoted 1 line
+static int
__devexitxenkbd_remove(struct xenbus_device *dev)Again, not convinced
__devexitis entirely valid here.
Same as above.
Quoted 11 lines
Quoted 11 lines
drivers/xen/xenkbd/xenkbd.c +10
-0+{ +struct xenkbd_info *info = dev->dev.driver_data; + +if (info->irq >=0 ) +unbind_from_irqhandler (info->irq, info); +input_unregister_device (info->dev); +free_page ((unsigned long )info->page); +kfree (info); +return 0 ; +}
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c line 238
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +6
-0+static struct xenbus_driver xenkbd = { + .name ="vkbd" , + .owner =THIS_MODULE , + .ids = xenkbd_ids, + .probe = xenkbd_probe, + .remove = xenkbd_remove,Again, might want to be
__devexit_p.
Same as above.
Quoted 13 lines
Quoted 13 lines
drivers/xen/xenkbd/xenkbd.c +13
-0+//.resume = xenkbd_resume, + .otherend_changed = xenkbd_backend_changed, +}; + +static int __init xenkbd_init (void ) +{ +int ret; + +if (!is_running_on_xen ()) +return -ENODEV ; + +/* Nothing to do if running in dom0. */ +if (is_initial_xendomain ())
Quoted 8 lines
drivers/xen/xenkbd/xenkbd.c
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +6
-0+return -ENODEV ; +/* if we're not set up to use graphics mode, then don't initialize */ +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &ret) <0 ) +return -ENODEV ; +if (ret ==0 ) +return -ENODEV ;This test obviously wants to be kept in sync with the corresponding test in
xenfb_init, so the same comments apply here as there.
Agreed.
Quoted 8 lines
include/xen/interface/io/xenfb.h
Quoted 6 lines
drivers/xen/xenkbd/xenkbd.c +2
-0+return xenbus_register_frontend (&xenkbd); +}diff -rupN -x '*.orig'
linux-2.6.16.29-xen/include/xen/interface/io/xenfb.hlinux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.hinclude/xen/interface/io/xenfb.h +0
-0I think this really wants to be in xen/include/public/io, but I'd guess this is just an artifact of the diff.
Where in the *Linux* tree you want it? include/xen/interface or include/xen/public or somewhere else?
Quoted 11 lines
Quoted 11 lines
include/xen/interface/io/xenfb.h +11
-0+struct xenfb_update +{ +__u8 type;/* XENFB_TYPE_UPDATE */ +__s32 x;/* source x */ +__s32 y;/* source y */ +__s32 width;/* rect width */ +__s32 height;/* rect height */ +}; + +#define XENFB_OUT_EVENT_SIZE 40 +
Quoted 8 lines
include/xen/interface/io/xenfb.h line 48
Quoted 6 lines
include/xen/interface/io/xenfb.h +6
-0+union xenfb_out_event +{ +__u8 type; +struct xenfb_update update; +char pad[XENFB_OUT_EVENT_SIZE ]; +};I still think you'd be better off doing tagged unions the usual way, but your funeral.
While I personally prefer Anthony's way to do it, I'd convert to yours if I could ensure the type's size remains exactly XENFB_OUT_EVENT_SIZE portably and without undue ugliness. Alternatively, if I could ensure the ring memory layout remains the same even when the type size changes.
Quoted 8 lines
Quoted 4 lines
+/*
+ * Wart: xenkbd needs to know resolution. Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */Why does xenkbd need to know the resolution? Do you mean xenfb?
As far as I can see, these only get used in
xenfb.c, so the #defines could go there rather than in the IO description header.
That's where they used to be. But xenkbd needs to tell the input layer about the resolution to make absolute pointer work.
Quoted 9 lines
include/xen/interface/io/xenfb.h line 116
Quoted 7 lines
include/xen/interface/io/xenfb.h +7
-0+#ifdef __KERNEL__ +#define XENFB_WIDTH 800 +#define XENFB_HEIGHT 600 +#define XENFB_DEPTH 32 +#endif + +#endif Steven.
Quoted 14 lines
Quoted 8 lines
drivers/xen/xenfb/xenfb.c line 485
Quoted 8 lines
drivers/xen/xenfb/xenfb.c +8
-0+ ret =fb_alloc_cmap (&fb_info->cmap,256 ,0 ); +if (ret <0 ) { +framebuffer_release (fb_info); +xenbus_dev_fatal (dev, ret,"fb_alloc_cmap" ); + goto error; + } + +/* FIXME should this be delayed until backend XenbusStateConnected? */ Quoted 5 lines
I would, but I'm not sure it matters too much. You have a potentially slightly confusing situation where someone starts using the framebuffer before the backend connects, so the backend has to be able to handle there being events on the ring when it starts, but I think it probably works as it is.
Quoted 3 lines
Yes, it works.
I might move it eventually just for cleanliness.
Actually, thinking about it, it probably does want to stay where it is, at least if you want to support backend disconnect/reconnect cleanly. If you kill the backend and restart it, _probe shouldn't get run a second time, whereas the state machine transitions probably will be. You probably want to present the same device to Linux, so re-registering might not be a good idea.
Quoted 10 lines
Quoted 9 lines
drivers/xen/xenfb/xenfb.c line 499
Quoted 5 lines
drivers/xen/xenfb/xenfb.c +5
-0+ info->kthread =kthread_run (xenfb_thread, info,"xenfb thread" ); +if (IS_ERR (info->kthread)) { + ret =PTR_ERR (info->kthread); +xenbus_dev_fatal (dev, ret,"register_framebuffer" ); + goto error;goto error will end up calling
xenfb_remove, which will notice thatinfo->kthreadis non-NULL and try tokthread_stopit. That strikes me as a bad idea.
...Oops. Thanks for catching.
np.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
+static int
__devexitxenfb_remove(struct xenbus_device *dev)This gets called from some error paths even when the driver is remaining loaded. Is
__devexitsafe? I'm thinking particularly of the case where the kernel is compiled without module unloading and discards exit text segments.Insufficient understanding of
__devexiton my part. Fixing.
Yeah, I had to go and look it up.
Quoted 29 lines
Quoted 21 lines
Quoted 21 lines
drivers/xen/xenfb/xenfb.c +21
-0+{ +struct xenfb_info *info = dev->dev.driver_data; + +del_timer (&info->refresh); +if (info->kthread) +kthread_stop (info->kthread); +if (info->irq >=0 ) +unbind_from_irqhandler (info->irq, info); +if (info->fb_info) { +unregister_framebuffer (info->fb_info); +fb_dealloc_cmap (&info->fb_info->cmap); +framebuffer_release (info->fb_info); + } +free_page ((unsigned long )info->page); +vfree (info->mfns); +kfree (info->pages); +vfree (info->fb); +kfree (info); + +return 0 ; +}Quoted 8 lines
drivers/xen/xenfb/xenfb.c line 606
Quoted 7 lines
drivers/xen/xenfb/xenfb.c +7
-0+ +static struct xenbus_driver xenfb = { + .name ="vfb" , + .owner =THIS_MODULE , + .ids = xenfb_ids, + .probe = xenfb_probe, + .remove = xenfb_remove,I think this wants to be
__devexit_p.
Quoted 1 line
Only if xenfb is
__devexit, right?
Yes, so if xenfb_remove loses __devexit this is correct.
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
drivers/xen/xenfb/xenfb.c +14
-0+/* TODO .resume = xenfb_resume, */ + .otherend_changed = xenfb_backend_changed, +}; + +static int __init xenfb_init (void ) +{ +int ret; + +if (!is_running_on_xen ()) +return -ENODEV ; + +/* Nothing to do if running in dom0. */ +if (is_initial_xendomain ()) +return -ENODEV ;Quoted 8 lines
drivers/xen/xenfb/xenfb.c line 625
Quoted 5 lines
drivers/xen/xenfb/xenfb.c +5
-0+/* if we're not set up to use graphics mode, then don't initialize */ +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &ret) <0 ) +return -ENODEV ; +if (ret ==0 ) +return -ENODEV ;Not sure about this. It seems to me like it might be useful to sometimes have domains which have a PVFB but still use xencons for kernel printks etc. Perhaps I'm just confused.
Quoted 1 line
I guess you're right.
Thanks.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
drivers/xen/xenkbd/xenkbd.c +3
-0+int __devinit xenkbd_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{...
drivers/xen/xenkbd/xenkbd.c line 112
Quoted 5 lines
drivers/xen/xenkbd/xenkbd.c +5
-0+ input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); + input_dev->keybit[LONG (BTN_MOUSE )] + =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); +/* FIXME more buttons? */ + input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );Do you need to set some bits in absbit, as well, since you can generate absolute coordinate messages?
Quoted 3 lines
We missed that. Curiously, everything seems to work all the same (as tested with evdev). Apparently, no consumer actually tests the bits correctly.
Figures.
Quoted 1 line
Fixing anyway.
Thanks.
Quoted 7 lines
Quoted 5 lines
include/xen/interface/io/xenfb.h
Quoted 3 lines
diff -rupN -x '*.orig'
linux-2.6.16.29-xen/include/xen/interface/io/xenfb.hlinux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.hinclude/xen/interface/io/xenfb.h +0
-0I think this really wants to be in xen/include/public/io, but I'd guess this is just an artifact of the diff.
Where in the *Linux* tree you want it?
include/xen/interfaceorinclude/xen/publicor somewhere else?
The IO header files all go in xen/include/public/io, with symlinks from linux/include/xen/interface/io. Your tree may be different due to de-sparseification. If that's all it is then I'll just ignore this from now on.
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
include/xen/interface/io/xenfb.h +11
-0+struct xenfb_update +{ +__u8 type;/* XENFB_TYPE_UPDATE */ +__s32 x;/* source x */ +__s32 y;/* source y */ +__s32 width;/* rect width */ +__s32 height;/* rect height */ +}; + +#define XENFB_OUT_EVENT_SIZE 40 +Quoted 8 lines
include/xen/interface/io/xenfb.h line 48
Quoted 6 lines
include/xen/interface/io/xenfb.h +6
-0+union xenfb_out_event +{ +__u8 type; +struct xenfb_update update; +char pad[XENFB_OUT_EVENT_SIZE ]; +};I still think you'd be better off doing tagged unions the usual way, but your funeral.
Quoted 5 lines
While I personally prefer Anthony's way to do it, I'd convert to yours if I could ensure the type's size remains exactly
XENFB_OUT_EVENT_SIZEportably and without undue ugliness. Alternatively, if I could ensure the ring memory layout remains the same even when the type size changes.
How about something like this:
struct xenfb_out_event {
__u8 type;
__u8 pad1[7];
union {
struct xenfb_update update;
__u8 pad[XENFB_OUT_SIZE-8];
} u;
};Does this satisfy your requirements? Admittedly, I've had to move some padding around to get good alignment, which I'd forgotten about before and makes it look a bit uglier than I was hoping, but I'd still say this is a little nicer.
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
+/*
+ * Wart: xenkbd needs to know resolution. Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */Why does xenkbd need to know the resolution? Do you mean xenfb?
As far as I can see, these only get used in
xenfb.c, so the #defines could go there rather than in the IO description header.That's where they used to be. But xenkbd needs to tell the input layer about the resolution to make absolute pointer work.
That's really quite unfortunate, and is going to cause problems when you start supporting changes in resolution.
Does the resolution reported by xenkbd actually need to match the resolution of the framebuffer? Could you report a resolution of 65536x65536 and then have the backend scale it? Presumably, a real tablet won't scale its output to match the display resolution.
Steven.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 16 lines · Steven Smith
Quoted 16 lines
Quoted 8 lines
drivers/xen/xenfb/xenfb.c line 485
Quoted 8 lines
drivers/xen/xenfb/xenfb.c +8
-0+ ret =fb_alloc_cmap (&fb_info->cmap,256 ,0 ); +if (ret <0 ) { +framebuffer_release (fb_info); +xenbus_dev_fatal (dev, ret,"fb_alloc_cmap" ); + goto error; + } + +/* FIXME should this be delayed until backend XenbusStateConnected? */ Quoted 5 lines
I would, but I'm not sure it matters too much. You have a potentially slightly confusing situation where someone starts using the framebuffer before the backend connects, so the backend has to be able to handle there being events on the ring when it starts, but I think it probably works as it is.
Yes, it works.
Quoted 7 lines
Quoted 1 line
I might move it eventually just for cleanliness.
Actually, thinking about it, it probably does want to stay where it is, at least if you want to support backend disconnect/reconnect cleanly. If you kill the backend and restart it,
_probeshouldn't get run a second time, whereas the state machine transitions probably will be. You probably want to present the same device to Linux, so re-registering might not be a good idea.
Yeah, that makes sense.
What about the kernel thread? I figure letting it run only while a backend is connected would make some sense. Anyway, no flawless diamond needed here for the initial merge.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/xen/xenfb/xenfb.c +5
-0+ info->kthread =kthread_run (xenfb_thread, info,"xenfb thread" ); +if (IS_ERR (info->kthread)) { + ret =PTR_ERR (info->kthread); +xenbus_dev_fatal (dev, ret,"register_framebuffer" ); + goto error;
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
drivers/xen/xenkbd/xenkbd.c +3
-0+int __devinit xenkbd_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{...
drivers/xen/xenkbd/xenkbd.c line 112
Quoted 5 lines
drivers/xen/xenkbd/xenkbd.c +5
-0+ input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); + input_dev->keybit[LONG (BTN_MOUSE )] + =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); +/* FIXME more buttons? */ + input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );Do you need to set some bits in absbit, as well, since you can generate absolute coordinate messages?
Quoted 7 lines
Quoted 3 lines
We missed that. Curiously, everything seems to work all the same (as tested with evdev). Apparently, no consumer actually tests the bits correctly.
Figures.
Quoted 1 line
Fixing anyway.
Thanks.
Haha, I found it: input_set_abs_params() takes care of absbit[] [...] automatically.
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
include/xen/interface/io/xenfb.h
Quoted 3 lines
diff -rupN -x '*.orig'
linux-2.6.16.29-xen/include/xen/interface/io/xenfb.hlinux-2.6.16.29-xen-vfb/include/xen/interface/io/xenfb.hinclude/xen/interface/io/xenfb.h +0
-0I think this really wants to be in xen/include/public/io, but I'd guess this is just an artifact of the diff.
Where in the *Linux* tree you want it?
include/xen/interfaceorinclude/xen/publicor somewhere else?The IO header files all go in xen/include/public/io, with symlinks from linux/include/xen/interface/io. Your tree may be different due to de-sparseification. If that's all it is then I'll just ignore this from now on.
Yes, that's all it is.
Quoted 35 lines
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
include/xen/interface/io/xenfb.h +11
-0+struct xenfb_update +{ +__u8 type;/* XENFB_TYPE_UPDATE */ +__s32 x;/* source x */ +__s32 y;/* source y */ +__s32 width;/* rect width */ +__s32 height;/* rect height */ +}; + +#define XENFB_OUT_EVENT_SIZE 40 +Quoted 8 lines
include/xen/interface/io/xenfb.h line 48
Quoted 6 lines
include/xen/interface/io/xenfb.h +6
-0+union xenfb_out_event +{ +__u8 type; +struct xenfb_update update; +char pad[XENFB_OUT_EVENT_SIZE ]; +};I still think you'd be better off doing tagged unions the usual way, but your funeral.
Quoted 5 lines
While I personally prefer Anthony's way to do it, I'd convert to yours if I could ensure the type's size remains exactly
XENFB_OUT_EVENT_SIZEportably and without undue ugliness. Alternatively, if I could ensure the ring memory layout remains the same even when the type size changes.How about something like this:
struct xenfb_out_event { __u8 type; __u8 pad1[7]; union { struct xenfb_update update; __u8 pad[XENFB_OUT_SIZE-8]; } u; };
Quoted 4 lines
Does this satisfy your requirements? Admittedly, I've had to move some padding around to get good alignment, which I'd forgotten about before and makes it look a bit uglier than I was hoping, but I'd still say this is a little nicer.
Umm, doesn't this make non-portable assumptions? What if __alignof(update) > 8? What if __alignof__(pad1) != 1? I admit I'd be surprised by the latter.
Even if we dismiss the portability problem as theoretical: isn't this padding game too clever by half?
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
+/*
+ * Wart: xenkbd needs to know resolution. Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */Why does xenkbd need to know the resolution? Do you mean xenfb?
As far as I can see, these only get used in
xenfb.c, so the #defines could go there rather than in the IO description header.That's where they used to be. But xenkbd needs to tell the input layer about the resolution to make absolute pointer work.
Quoted 7 lines
That's really quite unfortunate, and is going to cause problems when you start supporting changes in resolution.
Does the resolution reported by xenkbd actually need to match the resolution of the framebuffer? Could you report a resolution of 65536x65536 and then have the backend scale it? Presumably, a real tablet won't scale its output to match the display resolution.
I'm not worried about this right now. When we start supporting resolution change, we can figure out whether lying about the resolution works. If it doesn't, I'm sure we'll find a reasonable way to communicate the real resolution to xenkbd.
Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
+ /* FIXME should this be delayed until backend XenbusStateConnected? */
I would, but I'm not sure it matters too much. You have a potentially slightly confusing situation where someone starts using the framebuffer before the backend connects, so the backend has to be able to handle there being events on the ring when it starts, but I think it probably works as it is.
Yes, it works.
Quoted 7 lines
Quoted 1 line
I might move it eventually just for cleanliness.
Actually, thinking about it, it probably does want to stay where it is, at least if you want to support backend disconnect/reconnect cleanly. If you kill the backend and restart it,
_probeshouldn't get run a second time, whereas the state machine transitions probably will be. You probably want to present the same device to Linux, so re-registering might not be a good idea.
Quoted 5 lines
Yeah, that makes sense.
What about the kernel thread? I figure letting it run only while a backend is connected would make some sense. Anyway, no flawless diamond needed here for the initial merge.
I'm not bothered. Just do whatever's easier.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
drivers/xen/xenkbd/xenkbd.c line 112
Quoted 5 lines
drivers/xen/xenkbd/xenkbd.c +5
-0+ input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); + input_dev->keybit[LONG (BTN_MOUSE )] + =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); +/* FIXME more buttons? */ + input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );Do you need to set some bits in absbit, as well, since you can generate absolute coordinate messages?
We missed that. Curiously, everything seems to work all the same (as tested with evdev). Apparently, no consumer actually tests the bits correctly.
Quoted 6 lines
Quoted 4 lines
Figures.
Quoted 1 line
Fixing anyway.
Thanks.
Haha, I found it:
input_set_abs_params()takes care of absbit[] [...] automatically.
Ah, okay. Thanks for clearing that up for me.
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 2 lines
I still think you'd be better off doing tagged unions the usual way, but your funeral.
While I personally prefer Anthony's way to do it, I'd convert to yours if I could ensure the type's size remains exactly
XENFB_OUT_EVENT_SIZEportably and without undue ugliness. Alternatively, if I could ensure the ring memory layout remains the same even when the type size changes.How about something like this:
struct xenfb_out_event { __u8 type; __u8 pad1[7]; union { struct xenfb_update update; __u8 pad[XENFB_OUT_SIZE-8]; } u; };
Quoted 7 lines
Quoted 4 lines
Does this satisfy your requirements? Admittedly, I've had to move some padding around to get good alignment, which I'd forgotten about before and makes it look a bit uglier than I was hoping, but I'd still say this is a little nicer.
Umm, doesn't this make non-portable assumptions? What if
__alignof(update)> 8? What if__alignof__(pad1)!= 1? I admit I'd be surprised by the latter.
I'm quite happy to ignore this problem. Certainly 8 bit types which need more than 8 bit alignment are pretty unexpected, and I'd be amazed if we any of the standard integer types need more than 8 byte alignment on any reasonable architecture. If you're planning on sending weird SSE types across or something like that then you might have problems, but frankly at that point you deserve everything you get.
Quoted 2 lines
Even if we dismiss the portability problem as theoretical: isn't this padding game too clever by half?
You do need to think about padding to some extent when doing this sort of thing. One of the things which we'd like for new IO protocols is to have the same byte layout between 32 and 64 bit guests, so that you don't sabotage the ongoing work to get 32 bit guests working on 64 bit hosts. In the past, we've screwed up by relying on the compiler to insert implicit padding in e.g. the block request structure, and then discovered later on that it does it differently in 32 and 64 bit mode.
Making the padding explicit also makes it more obviously where you can insert fields if we decide that we want e.g. per-request flags in a few months' time.
Anyway, this whole issue is a bikeshed. Do whichever you prefer.
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
+/*
+ * Wart: xenkbd needs to know resolution. Put it here until a better
+ * solution is found, but don't leak it to the backend.
+ */Why does xenkbd need to know the resolution? Do you mean xenfb?
As far as I can see, these only get used in
xenfb.c, so the #defines could go there rather than in the IO description header.That's where they used to be. But xenkbd needs to tell the input layer about the resolution to make absolute pointer work.
That's really quite unfortunate, and is going to cause problems when you start supporting changes in resolution.
Quoted 8 lines
Quoted 4 lines
Does the resolution reported by xenkbd actually need to match the resolution of the framebuffer? Could you report a resolution of 65536x65536 and then have the backend scale it? Presumably, a real tablet won't scale its output to match the display resolution.
I'm not worried about this right now. When we start supporting resolution change, we can figure out whether lying about the resolution works. If it doesn't, I'm sure we'll find a reasonable way to communicate the real resolution to xenkbd.
Okay.
Steven.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PV framebuffer frontend. Derived from
http://www.cs.utexas.edu/users/aliguori/vfb-20060124.bundle
Extensive changes based on feedback from xen-devel.
--- arch/i386/kernel/setup-xen.c | 5 arch/ia64/kernel/setup.c | 4 arch/x86_64/kernel/setup-xen.c | 7 drivers/char/tty_io.c | 6 drivers/xen/Kconfig | 23 + drivers/xen/Makefile | 2 drivers/xen/console/console.c | 51 ++- drivers/xen/xenfb/Makefile | 1 drivers/xen/xenfb/xenfb.c | 642 ++++++++++++++++++++++++++++++++++++++ drivers/xen/xenkbd/Makefile | 1 drivers/xen/xenkbd/xenkbd.c | 271 ++++++++++++++++ include/xen/interface/io/xenfb.h | 116 ++++++ include/xen/interface/io/xenkbd.h | 108 ++++++ mm/memory.c | 1 14 files changed, 1221 insertions(+), 17 deletions(-)
arch/i386/kernel/setup-xen.c +3 -2
@@ -1850,8 +1850,9 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif } }
arch/ia64/kernel/setup.c +2 -2
@@ -550,9 +550,9 @@ setup_arch (char **cmdline_p) xen_start_info->nr_pages, xen_start_info->flags);if (!is_initial_xendomain ()) { -extern int console_use_vt; +#if !defined(CONFIG_VT ) || !defined(CONFIG_DUMMY_CONSOLE ) conswitchp =NULL ; - console_use_vt =0 ; +#endif } }#endif
arch/x86_64/kernel/setup-xen.c +4 -3
@@ -970,9 +970,10 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; - } +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif + } }#else /* CONFIG_XEN */
drivers/char/tty_io.c +1 -5
@@ -132,8 +132,6 @@ LIST_HEAD(tty_drivers); /* linked listvt.c for deeply disgusting hack reasons */ DECLARE_MUTEX (tty_sem); -int console_use_vt =1 ; -#ifdef CONFIG_UNIX98_PTYS extern struct tty_driver *ptm_driver;/* Unix98 pty masters; for /dev/ptmx */ extern int pty_limit;/* Config limit on Unix98 ptys */
@@ -2056,7 +2054,7 @@ retry_open: goto got_driver; }#ifdef CONFIG_VT -if (console_use_vt && (device ==MKDEV (TTY_MAJOR ,0 ))) { +if (device ==MKDEV (TTY_MAJOR ,0 )) {extern struct tty_driver *console_driver; driver = console_driver; index = fg_console;
@@ -3247,8 +3245,6 @@ static int __init tty_init(void)#endif #ifdef CONFIG_VT -if (!console_use_vt) - goto out_vt;cdev_init (&vc0_cdev, &console_fops);if (cdev_add (&vc0_cdev,MKDEV (TTY_MAJOR ,0 ),1 ) ||register_chrdev_region (MKDEV (TTY_MAJOR ,0 ),1 ,"/dev/vc/0" ) <0 )
drivers/xen/console/console.c +46 -5
116 lines not on this page · raw message
drivers/xen/Kconfig +23 -0
@@ -172,6 +172,29 @@ config XEN_NETDEV_FRONTEND dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_FRAMEBUFFER + tristate "Framebuffer-device frontend driver" + depends on XEN && FB + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + default y + help + The framebuffer-device frontend drivers allows the kernel to create a + virtual framebuffer. This framebuffer can be viewed in another + domain. Unless this domain has access to a real video card, you + probably want to say Y here. + +config XEN_KEYBOARD + tristate "Keyboard-device frontend driver" + depends on XEN && XEN_FRAMEBUFFER && INPUT + default y + help + The keyboard-device frontend driver allows the kernel to create a + virtual keyboard. This keyboard can then be driven by another + domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably + want to say Y here. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default y
drivers/xen/Makefile +2 -0
@@ -15,3 +15,5 @@ obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blk obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/ obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/ obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/ +obj-$(CONFIG_XEN_FRAMEBUFFER) += xenfb/ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd/
drivers/xen/xenfb/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_FRAMEBUFFER) := xenfb.o
drivers/xen/xenfb/xenfb.c +642 -0
642 lines not on this page · raw message
drivers/xen/xenkbd/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd.o
drivers/xen/xenkbd/xenkbd.c +271 -0
271 lines not on this page · raw message
include/xen/interface/io/xenfb.h +116 -0
116 lines not on this page · raw message
include/xen/interface/io/xenkbd.h +108 -0
108 lines not on this page · raw message
mm/memory.c +1 -0
@@ -882,6 +882,7 @@ unsigned long zap_page_range(struct vm_atlb_finish_mmu (tlb, address, end);return end; } +EXPORT_SYMBOL (zap_page_range);/* * Do a quick page-table lookup for a single page.
Diffs since last iteration:
drivers/xen/console/console.c +7 -12
@@ -712,18 +712,13 @@ static int __init xencons_init(void)printk ("Xen virtual console successfully installed as %s%d\n" ,DRV (xencons_driver)->name, xc_num); -/* Don't need to check about graphical fb for domain 0 */ -if (is_initial_xendomain ()) -return 0 ; - - rc =0 ; -if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &rc) <0 ) -printk (KERN_ERR "Unable to read console/use_graphics\n" ); -if (rc ==0 ) { -/* FIXME: this is ugly */ -unregister_console (&kcons_info); - kcons_info.flags |=CON_CONSDEV ; -register_console (&kcons_info); +/* Check about framebuffer messing up the console */ +if (!is_initial_xendomain () && + !xenbus_exists (XBT_NIL ,"device" ,"vfb" )) { +/* FIXME: this is ugly */ +unregister_console (&kcons_info); + kcons_info.flags |=CON_CONSDEV ; +register_console (&kcons_info); }return 0 ;
drivers/xen/Kconfig +1 -1
@@ -187,7 +187,7 @@ config XEN_FRAMEBUFFER config XEN_KEYBOARD tristate "Keyboard-device frontend driver" - depends on XEN + depends on XEN && XEN_FRAMEBUFFER && INPUT default y help The keyboard-device frontend driver allows the kernel to create a
drivers/xen/xenfb/xenfb.c +14 -10
@@ -67,7 +67,7 @@ struct xenfb_infostatic int xenfb_fps =20 ;static unsigned long xenfb_mem_len =XENFB_WIDTH *XENFB_HEIGHT *XENFB_DEPTH /8 ; -static int __devexit xenfb_remove(struct xenbus_device *); +static int xenfb_remove (struct xenbus_device *);static void xenfb_do_update (struct xenfb_info *info,int x,int y,int w,int h)
@@ -482,7 +482,6 @@ static int __devinit xenfb_probe(struct goto error; } -/* FIXME should this be delayed until backend XenbusStateConnected? */ ret =register_framebuffer (fb_info);if (ret) {fb_dealloc_cmap (&info->fb_info->cmap);
@@ -492,9 +491,11 @@ static int __devinit xenfb_probe(struct } info->fb_info = fb_info; +/* FIXME should this be delayed until backend XenbusStateConnected? */ info->kthread =kthread_run (xenfb_thread, info,"xenfb thread" );if (IS_ERR (info->kthread)) { ret =PTR_ERR (info->kthread); + info->kthread =NULL ;xenbus_dev_fatal (dev, ret,"register_framebuffer" ); goto error; }
@@ -553,10 +554,19 @@ static void xenfb_backend_changed(structbreak ;case XenbusStateInitWait: + InitWait:xenbus_switch_state (dev, XenbusStateConnected);break ;case XenbusStateConnected: +/* +* Work around xenbus race condition: If backend goes +* through InitWait to Connected fast enough, we can +* get Connected twice here. +*/ +if (dev->state != XenbusStateConnected) + goto InitWait;/* no InitWait seen yet, fudge it */ +if (xenbus_scanf (XBT_NIL , info->xbdev->otherend,"request-update" ,"%d" , &val) <0 ) val =0 ;
@@ -565,12 +575,13 @@ static void xenfb_backend_changed(structbreak ;case XenbusStateClosing: +// FIXME is this safe in any dev->state? xenbus_frontend_closed (dev);break ; } } -static int __devexit xenfb_remove(struct xenbus_device *dev) +static int xenfb_remove (struct xenbus_device *dev) {struct xenfb_info *info = dev->dev.driver_data;
@@ -610,19 +621,12 @@ static struct xenbus_driver xenfb = {static int __init xenfb_init (void ) { -int ret; -if (!is_running_on_xen ())return -ENODEV ;/* Nothing to do if running in dom0. */ if (is_initial_xendomain ())return -ENODEV ; -/* if we're not set up to use graphics mode, then don't initialize */ -if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &ret) <0 ) -return -ENODEV ; -if (ret ==0 ) -return -ENODEV ;return xenbus_register_frontend (&xenfb); }
drivers/xen/xenkbd/xenkbd.c +11 -11
@@ -36,7 +36,7 @@ struct xenkbd_infostruct xenbus_device *xbdev; }; -static int __devexit xenkbd_remove(struct xenbus_device *); +static int xenkbd_remove (struct xenbus_device *);/* * Note: if you need to send out events, see xenfb_do_update() for how
@@ -108,7 +108,7 @@ int __devinit xenkbd_probe(struct xenbus input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REL ) |BIT (EV_ABS ); input_dev->keybit[LONG (BTN_MOUSE )] =BIT (BTN_LEFT ) |BIT (BTN_MIDDLE ) |BIT (BTN_RIGHT ); -/* FIXME more buttons? */ +/* TODO additional buttons */ input_dev->relbit[0 ] =BIT (REL_X ) |BIT (REL_Y );/* FIXME not sure this is quite right */
@@ -191,6 +191,7 @@ static void xenkbd_backend_changed(strucbreak ;case XenbusStateInitWait: + InitWait: ret =xenbus_scanf (XBT_NIL , info->xbdev->otherend,"feature-abs-pointer" ,"%d" , &val);if (ret <0 )
@@ -205,6 +206,13 @@ static void xenkbd_backend_changed(strucbreak ;case XenbusStateConnected: +/* +* Work around xenbus race condition: If backend goes +* through InitWait to Connected fast enough, we can +* get Connected twice here. +*/ +if (dev->state != XenbusStateConnected) + goto InitWait;/* no InitWait seen yet, fudge it */ break ;case XenbusStateClosing:
@@ -213,7 +221,7 @@ static void xenkbd_backend_changed(struc } } -static int __devexit xenkbd_remove(struct xenbus_device *dev) +static int xenkbd_remove (struct xenbus_device *dev) {struct xenkbd_info *info = dev->dev.driver_data;
@@ -242,20 +250,12 @@ static struct xenbus_driver xenkbd = {static int __init xenkbd_init (void ) { -int ret; -if (!is_running_on_xen ())return -ENODEV ;/* Nothing to do if running in dom0. */ if (is_initial_xendomain ())return -ENODEV ; -/* if we're not set up to use graphics mode, then don't initialize */ -if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &ret) <0 ) -return -ENODEV ; -if (ret ==0 ) -return -ENODEV ; -return xenbus_register_frontend (&xenkbd); }
mm/memory.c +1 -0
@@ -882,6 +882,7 @@ unsigned long zap_page_range(struct vm_atlb_finish_mmu (tlb, address, end);return end; } +EXPORT_SYMBOL (zap_page_range);/* * Do a quick page-table lookup for a single page.
Quoted 1 line · Markus Armbruster
Steven Smith <[email protected]> writes:
[...]
Quoted 40 lines
Quoted 40 lines
Quoted 10 lines
diff -rupN -x '*.orig'
linux-2.6.16.29-xen/drivers/xen/console/console.clinux-2.6.16.29-xen-vfb/drivers/xen/console/console.cdrivers/xen/console/console.c +3
-0@@ -680,3 +712,17 @@ static int __init xencons_init(void)printk ("Xen virtual console successfully installed as %s%d\n" ,DRV (xencons_driver)->name, xc_num); +/* Don't need to check about graphical fb for domain 0 */ +if (is_initial_xendomain ()) +return 0 ;drivers/xen/console/console.c static int __init xencons_init(void) · line 727
Quoted 10 lines
drivers/xen/console/console.c +10
-0+ + rc =0 ; +if (xenbus_scanf (XBT_NIL ,"console" ,"use_graphics" ,"%d" , &rc) <0 ) +printk (KERN_ERR "Unable to read console/use_graphics\n" ); +if (rc ==0 ) { +/* FIXME: this is ugly */ +unregister_console (&kcons_info); + kcons_info.flags |=CON_CONSDEV ; +register_console (&kcons_info); + }I'm still not entirely sure I understand why this bit is necessary.
From talking to [email protected] last time:
Quoted 14 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Also, why do you need to set
CON_CONSDEVat all?Otherwise, you don't get kernel console messages.
Why not? None of the other console drivers seem to need to set it explicitly, and it seems like it would break setting console=blah on the kernel command line.
Nothing else sets it explicitly because it happens implicitly in the console registration code for the first thing registered with
register_console(). Alternately, if you have a console=, thenregister_consoleensures that your console device hasCON_CONSDEVset.kernel/printk.cif you want to read all the gory detailsThe intent of this code seems to be to make sure that
CON_CONSDEVis definitely set on xenconsole ifuse_graphicsis not set, yes? But as far as I can see, ifuse_graphicsis not set, xenfb should never callregister_console(), and so this is all redundant.
Quoted 6 lines
Quoted 4 lines
I'm still just as unenlightened as I was then. Plus,
xen_console_initshould be called before any of the pvfb stuff anyway, since it's aconsole_initcalland pvfb starts from amodule_init, so it's doubly redundant.Jeremy, could you elaborate?
Jeremy is buried alive in email right now. This is what he wrote to me, quoted with permission:
The reason why this is needed is because the Linux console code is a mess. xen_console_init _does_ get called earlier but dummycon gets initialized first and ends up as the primary console. When the fb layer starts going, xenfb takes over from dummycon and it's the primary console. All good if you're wanting the fb. If you're _not_ though and you have it any of the VC stuff compiled into the kernel, then you need to reset xencons as the actual primary console dev.
The better thing to do in the longer term is to actually have a xen_early_console along the lines of the ppc early console stuff (see viocons_early in drivers/char/viocons.c) so that you're doing a sane hand-off. But the (reasonable, IMHO) consensus after the last cycle was to do that as a separate patch set as it's not fundamentally related to the pvfb stuff.
If I understand this correctly, the hack is required to make xencons working when xenfb is compiled in but not active.
Since we let xend create the xenstore for the devices now, we can check whether the frontend device is in xenstore here, and drop console/use_graphics. We could also conditionalize on XEN_FRAMEBUFFER, but I doubt it's worth the bother.
[...]
PV framebuffer frontend. Derived from
http://www.cs.utexas.edu/users/aliguori/vfb-20060124.bundle
Extensive changes based on feedback from xen-devel.
--- arch/i386/kernel/setup-xen.c | 5 arch/ia64/kernel/setup.c | 4 arch/x86_64/kernel/setup-xen.c | 7 drivers/char/tty_io.c | 6 drivers/xen/Kconfig | 23 + drivers/xen/Makefile | 2 drivers/xen/console/console.c | 44 ++ drivers/xen/xenfb/Makefile | 1 drivers/xen/xenfb/xenfb.c | 682 ++++++++++++++++++++++++++++++++++++++ drivers/xen/xenkbd/Makefile | 1 drivers/xen/xenkbd/xenkbd.c | 300 ++++++++++++++++ include/xen/interface/io/xenfb.h | 116 ++++++ include/xen/interface/io/xenkbd.h | 108 ++++++ mm/memory.c | 1 14 files changed, 1284 insertions(+), 16 deletions(-)
arch/i386/kernel/setup-xen.c +3 -2
@@ -1850,8 +1850,9 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif } }
arch/ia64/kernel/setup.c +2 -2
@@ -550,9 +550,9 @@ setup_arch (char **cmdline_p) xen_start_info->nr_pages, xen_start_info->flags);if (!is_initial_xendomain ()) { -extern int console_use_vt; +#if !defined(CONFIG_VT ) || !defined(CONFIG_DUMMY_CONSOLE ) conswitchp =NULL ; - console_use_vt =0 ; +#endif } }#endif
arch/x86_64/kernel/setup-xen.c +4 -3
@@ -970,9 +970,10 @@ void __init setup_arch(char **cmdline_p)#endif #endif }else { -extern int console_use_vt; - console_use_vt =0 ; - } +#if defined(CONFIG_VT ) && defined(CONFIG_DUMMY_CONSOLE ) + conswitchp = &dummy_con; +#endif + } }#else /* CONFIG_XEN */
drivers/char/tty_io.c +1 -5
@@ -132,8 +132,6 @@ LIST_HEAD(tty_drivers); /* linked listvt.c for deeply disgusting hack reasons */ DECLARE_MUTEX (tty_sem); -int console_use_vt =1 ; -#ifdef CONFIG_UNIX98_PTYS extern struct tty_driver *ptm_driver;/* Unix98 pty masters; for /dev/ptmx */ extern int pty_limit;/* Config limit on Unix98 ptys */
@@ -2056,7 +2054,7 @@ retry_open: goto got_driver; }#ifdef CONFIG_VT -if (console_use_vt && (device ==MKDEV (TTY_MAJOR ,0 ))) { +if (device ==MKDEV (TTY_MAJOR ,0 )) {extern struct tty_driver *console_driver; driver = console_driver; index = fg_console;
@@ -3247,8 +3245,6 @@ static int __init tty_init(void)#endif #ifdef CONFIG_VT -if (!console_use_vt) - goto out_vt;cdev_init (&vc0_cdev, &console_fops);if (cdev_add (&vc0_cdev,MKDEV (TTY_MAJOR ,0 ),1 ) ||register_chrdev_region (MKDEV (TTY_MAJOR ,0 ),1 ,"/dev/vc/0" ) <0 )
drivers/xen/console/console.c +40 -4
109 lines not on this page · raw message
drivers/xen/Kconfig +23 -0
@@ -172,6 +172,29 @@ config XEN_NETDEV_FRONTEND dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_FRAMEBUFFER + tristate "Framebuffer-device frontend driver" + depends on XEN && FB + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + default y + help + The framebuffer-device frontend drivers allows the kernel to create a + virtual framebuffer. This framebuffer can be viewed in another + domain. Unless this domain has access to a real video card, you + probably want to say Y here. + +config XEN_KEYBOARD + tristate "Keyboard-device frontend driver" + depends on XEN && XEN_FRAMEBUFFER && INPUT + default y + help + The keyboard-device frontend driver allows the kernel to create a + virtual keyboard. This keyboard can then be driven by another + domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably + want to say Y here. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default y
drivers/xen/Makefile +2 -0
@@ -15,3 +15,5 @@ obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blk obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/ obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/ obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/ +obj-$(CONFIG_XEN_FRAMEBUFFER) += xenfb/ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd/
drivers/xen/xenfb/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_FRAMEBUFFER) := xenfb.o
drivers/xen/xenfb/xenfb.c +682 -0
682 lines not on this page · raw message
drivers/xen/xenkbd/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XEN_KEYBOARD) += xenkbd.o
drivers/xen/xenkbd/xenkbd.c +300 -0
300 lines not on this page · raw message
include/xen/interface/io/xenfb.h +116 -0
116 lines not on this page · raw message
include/xen/interface/io/xenkbd.h +108 -0
108 lines not on this page · raw message
mm/memory.c +1 -0
@@ -882,6 +882,7 @@ unsigned long zap_page_range(struct vm_atlb_finish_mmu (tlb, address, end);return end; } +EXPORT_SYMBOL (zap_page_range);/* * Do a quick page-table lookup for a single page.