xen pvfb: Para-virtual framebuffer, keyboard and pointer
Subsystems (7)
cover xen pvfb: Para-virtual framebuffer, keyboard and pointer
This is a pair of Xen para-virtual frontend device drivers:drivers/video/xen-fbfront.c provides a framebuffer, and drivers/input/xen-kbdfront provides keyboard and mouse.
The backends run in dom0 user space.
Differences since last post:
* Required patch fixing 32-on-64 xen-blkfront included.
* Cleanup when xenkbd_probe() fails fixed.
* Don't store event channel in device info.
I started with the Xen version at
http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/ca05cf1a9bdc
Differences to that Xen version, for those who care:
* Rewritten on top of fb deferred I/O
* IRQ handler names visible in /proc and /sys match the driver names.
* Use framebuffer helper functions appropriate for framebuffer in system RAM.
* write() refreshes the framebuffer properly.
* off-by-one height of some screen refreshs fixed.
* Crash when register_framebuffer() fails fixed.
* Test for empty ring in input_handler() fixed.
* Deadlock in xen-kbdfront resume fixed.
* Cleanup when xenkbd_probe() fails fixed.
* General clean up.
I have a step-by-step patch series from that Xen version to my version, if anybody is interested. Might be useful for reviewers familiar with the Xen version.
The patch consists of three parts:
1. xen: Make xen-blkfront write its protocol ABI to xenstore
Could do without, but then I'd have to put the same bug in xen-fbfront and xen-kbdfront.
2. fbdev: Make deferred I/O work as advertized
I need fb deferred I/O, but is utterly broken. A fix has been floating around on linux-fbdev-devel as part of a larger patch, which as far as I know has not been merged anywhere, yet. This is just the fix.
2. xen pvfb: Para-virtual framebuffer, keyboard and pointer driver
The actual drivers.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 1/3 xen: Make xen-blkfront write its protocol ABI to xenstore
Frontends are expected to write their protocol ABI to xenstore. Since the protocol ABI defaults to the backend's native ABI, things work fine without that as long as the frontend's native ABI is identical to the backend's native ABI. This is not the case for xen-blkfront running 32-on-64, because its ABI differs between 32 and 64 bit, and thus needs this fix.
Based on http://xenbits.xensource.com/xen-unstable.hg?rev/c545932a18f3
and http://xenbits.xensource.com/xen-unstable.hg?rev/ffe52263b430 by Gerd Hoffmann <[email protected]>
--- drivers/block/xen-blkfront.c | 7 +++++++ include/xen/interface/io/protocols.h | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) create mode 100644 include/xen/interface/io/protocols.h
drivers/block/xen-blkfront.c +7 -0
@@ -46,6 +46,7 @@#include <xen/interface/grant_table.h> #include <xen/interface/io/blkif.h> +#include <xen/interface/io/protocols.h> #include <asm/xen/hypervisor.h>
@@ -597,6 +598,12 @@ again: message ="writing event-channel" ; goto abort_transaction; } + err =xenbus_printf (xbt, dev->nodename,"protocol" ,"%s" , +XEN_IO_PROTO_ABI_NATIVE ); +if (err) { + message ="writing protocol" ; + goto abort_transaction; + } err =xenbus_transaction_end (xbt,0 );if (err) {
include/xen/interface/io/protocols.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef __XEN_PROTOCOLS_H__ +#define __XEN_PROTOCOLS_H__ + +#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" +#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" +#define XEN_IO_PROTO_ABI_IA64 "ia64-abi" +#define XEN_IO_PROTO_ABI_POWERPC64 "powerpc64-abi" + +#if defined(__i386__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 +#elif defined(__x86_64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 +#elif defined(__ia64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64 +#elif defined(__powerpc64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64 +#else +# error arch fixup needed here +#endif + +#endif
Signature · 7 lines
1.5.3.3 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 2/3 fbdev: Make deferred I/O work as advertized
In reply to Markus ArmbrusterDeferred I/O was utterly broken. Reading the mmap()ed framebuffer worked, but writing it made the VM endlessly invoke vm_ops.page_mkwrite(). That happened because we failed to set page->mapping and page->index.
The fix is to set them, and clean up properly before the framebuffer gets released.
Fix extracted from this linux-fbdev-devel message:
Subject: [PATCH 1/1 2.6.24] fbdev: defio and Metronomefb
From: Jaya Kumar <[email protected]>
Date: 2008-02-18 13:41:26
---
drivers/video/fb_defio.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/video/fb_defio.c +20 -2
@@ -4,7 +4,7 @@* Copyright (C) 2006 Jaya Kumar * * This file is subject to the terms and conditions of the GNU General Public -* License. See the file COPYING in the main directory of this archive +* License. See the file COPYING in the main directory of this archive * for more details. */
@@ -31,7 +31,7 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma,unsigned long offset;struct page *page;struct fb_info *info = vma->vm_private_data; -/* info->screen_base is in System RAM */ +/* info->screen_base is virtual memory */ void *screen_base = (void __force *) info->screen_base; offset = vmf->pgoff <<PAGE_SHIFT ;
@@ -43,6 +43,15 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma,return VM_FAULT_SIGBUS ;get_page (page); + +if (vma->vm_file) + page->mapping = vma->vm_file->f_mapping; +else +printk (KERN_ERR "no mapping available\n" ); + +BUG_ON (!page->mapping); + page->index = vmf->pgoff; + vmf->page = page;return 0 ; }
@@ -138,11 +147,20 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_init);void fb_deferred_io_cleanup (struct fb_info *info) { +void *screen_base = (void __force *) info->screen_base;struct fb_deferred_io *fbdefio = info->fbdefio; +struct page *page; +int i;BUG_ON (!fbdefio);cancel_delayed_work (&info->deferred_work);flush_scheduled_work (); + +/* clear out the mapping that we setup */ +for (i =0 ; i < info->fix.smem_len; i +=PAGE_SIZE ) { + page =vmalloc_to_page (screen_base + i); + page->mapping =NULL ; + } }EXPORT_SYMBOL_GPL (fb_deferred_io_cleanup);
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 4 lines · Markus Armbruster
Subject: [PATCH 1/1 2.6.24] fbdev: defio and Metronomefb
From: Jaya Kumar <[email protected]>
Date: 2008-02-18 13:41:26
Hi Markus,
Andrew pointed out that there may be race conditions associated with this patch. [ http://marc.info/?l=linux-fbdev-devel&m=120376473020396&w=2
] So I would not encourage anyone to merge it. I'll try to figure things out this weekend.
Thanks,
jaya
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 8 lines · Jaya Kumar
Quoted 4 lines · Markus Armbruster
Subject: [PATCH 1/1 2.6.24] fbdev: defio and Metronomefb
From: Jaya Kumar <[email protected]>
Date: 2008-02-18 13:41:26Hi Markus,
Quoted 7 lines
Andrew pointed out that there may be race conditions associated with this patch. [ http://marc.info/?l=linux-fbdev-devel&m=120376473020396&w=2
] So I would not encourage anyone to merge it. I'll try to figure things out this weekend.Thanks,
jaya
Thanks for the timely info. I'm not in an undue hurry to get this merged. As long as we're moving forward, I'm happy.
What about pushing the fb_defio fixes independently of any new fb_defio users? If fb_defio was worth merging into Linus's tree, it should be worth fixing there, whether new users are in shape already or not.
If we must have a new user, well, I could easily whip up something like FB_VIRTUAL on top of fb_defio.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 5 lines · Markus Armbruster
What about pushing the
fb_defiofixes independently of any newfb_defiousers? Iffb_defiowas worth merging into Linus's tree, it should be worth fixing there, whether new users are in shape already or not.
I think that Andrew's message is saying that there may be a race condition in the defio patch itself as opposed to the defio user patch.
If there is no race condition or other problems, then I think it would make sense to merge the defio patch independent of metronomefb or other new patches that use defio.
Thanks,
jaya
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 11 lines · Jaya Kumar
Quoted 5 lines · Markus Armbruster
What about pushing the
fb_defiofixes independently of any newfb_defiousers? Iffb_defiowas worth merging into Linus's tree, it should be worth fixing there, whether new users are in shape already or not.I think that Andrew's message is saying that there may be a race condition in the defio patch itself as opposed to the defio user patch.
Quoted 6 lines
If there is no race condition or other problems, then I think it would make sense to merge the defio patch independent of metronomefb or other new patches that use defio.
Thanks,
jaya
Any progress on this?
Considering that fb_defio is utterly broken without the fix (writing the frame buffer makes the VM endlessly invoke vm_ops.page_mkwrite()), wouldn't it make sense to merge the fix even if it still has issues?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 7 lines · Markus Armbruster
Any progress on this?
Considering that
fb_defiois utterly broken without the fix (writing the frame buffer makes the VM endlessly invokevm_ops.page_mkwrite()), wouldn't it make sense to merge the fix even if it still has issues?
Yes, Andrew has merged the fix into -mm. I see it in mmotm
http://userweb.kernel.org/~akpm/mmotm/broken-out/fbdev-defio-and-metronomefb-v4.patch
Thanks,
jaya
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 4 lines · On Wed, 19 Mar 2008 19:24:25 +0800 "Jaya Kumar" <[email protected]>…
Quoted 3 lines · Markus Armbruster
Any progress on this?
Quoted 9 lines
Quoted 4 lines
Considering that
fb_defiois utterly broken without the fix (writing the frame buffer makes the VM endlessly invokevm_ops.page_mkwrite()), wouldn't it make sense to merge the fix even if it still has issues?Yes, Andrew has merged the fix into -mm. I see it in mmotm
http://userweb.kernel.org/~akpm/mmotm/broken-out/fbdev-defio-and-metronomefb-v4.patch
Do we need some of all of that patch in 2.6.25? I wasn't aware of such a need.
If the drivers/video/fb_defio.c hunk of that patch fixes something then I'd be inclined to merge the whole thing - adding a new driver won't hurt anyone.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 8 lines · Andrew Morton
Do we need some of all of that patch in 2.6.25? I wasn't aware of such a need.
If the
drivers/video/fb_defio.chunk of that patch fixes something then I'd be inclined to merge the whole thing - adding a new driver won't hurt anyone.
Yes, the defio hunk is a bugfix. I agree with pushing the whole thing to 2.6.25 if there are people who need it in 2.6.25. I believe there is no risk of impact on anyone else.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 6 lines · On Thu, 20 Mar 2008 06:30:37 +0800 "Jaya Kumar" <[email protected]>…
Quoted 4 lines · Andrew Morton
Do we need some of all of that patch in 2.6.25? I wasn't aware of such a need.
Quoted 9 lines
Quoted 4 lines
If the
drivers/video/fb_defio.chunk of that patch fixes something then I'd be inclined to merge the whole thing - adding a new driver won't hurt anyone.Yes, the defio hunk is a bugfix. I agree with pushing the whole thing to 2.6.25 if there are people who need it in 2.6.25. I believe there is no risk of impact on anyone else.
Well all we have in the changelog is
Implement support for the E-Ink Metronome controller. It provides an mmapable interface to the controller using defio support. It was tested with a gumstix pxa255 with Vizplex media using Xfbdev and various X clients such as xeyes, xpdf, xloadimage.
grump. This say nothing at all about the change to drivers/video/fb_defio.c.
a) the changelog _should_ document this change. Please send a paragraph and I'll add it.
b) If this discussion hadn't happened, that bug (whatever it is) would have remained unfixed in 2.6.25. As a direct consequence of poor changelogging.
c) This bugfix (whatever it is) should have been in a separate patch.
Thanks.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/3] fbdev: Make deferred I/O work as advertized
Quoted 9 lines · Andrew Morton
Well all we have in the changelog is
Implement support for the E-Ink Metronome controller. It provides an mmapable interface to the controller using defio support. It was tested with a gumstix pxa255 with Vizplex media using Xfbdev and various X clients such as xeyes, xpdf, xloadimage.
grump. This say nothing at all about the change to
drivers/video/fb_defio.c.
I apologize. I should have done better.
Quoted 3 lines
a) the changelog _should_ document this change. Please send a paragraph and I'll add it.
This patch fixes the following bug. Defio would cause a hang on write access to the framebuffer as the page fault would be called ad-infinitum. It fixes fb_defio by setting the mapping to be used by page_mkclean.
Quoted 4 lines
b) If this discussion hadn't happened, that bug (whatever it is) would have remained unfixed in 2.6.25. As a direct consequence of poor changelogging.
Understood. The root cause of my flaw was my assumption that other than me, there weren't any users of defio so I was in no hurry to get it fixed.
Quoted 2 lines
c) This bugfix (whatever it is) should have been in a separate patch.
Understood. It won't happen again.
Thanks,
jaya
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 3/3 xen pvfb: Para-virtual framebuffer, keyboard and pointer driver
In reply to Markus ArmbrusterThis is a pair of Xen para-virtual frontend device drivers:drivers/video/xen-fbfront.c provides a framebuffer, and drivers/input/xen-kbdfront provides keyboard and mouse.
The backends run in dom0 user space.
The two drivers are not in two separate patches, because the intermediate step (one driver, not the other) is somewhat problematic:
the backend in dom0 needs both drivers, and will refuse to complete device initialization unless they're both present.
---
drivers/input/Kconfig | 9 drivers/input/Makefile | 2 drivers/input/xen-kbdfront.c | 340 ++++++++++++++++++++++++ drivers/video/Kconfig | 14 drivers/video/Makefile | 1 drivers/video/xen-fbfront.c | 550 +++++++++++++++++++++++++++++++++++++++ include/xen/interface/io/fbif.h | 124 ++++++++ include/xen/interface/io/kbdif.h | 114 ++++++++ 8 files changed, 1154 insertions(+)
drivers/input/Kconfig +9 -0
@@ -149,6 +149,15 @@ config INPUT_APMPOWER To compile this driver as a module, choose M here: the module will be called apm-power. +config XEN_KBDDEV_FRONTEND + tristate "Xen virtual keyboard and mouse support" + depends on XEN_FBDEV_FRONTEND + default y + help + This driver implements the front-end of the Xen virtual + keyboard and mouse device driver. It communicates with a back-end + in another domain. + comment "Input Device Drivers" source "drivers/input/keyboard/Kconfig"
drivers/input/Makefile +2 -0
@@ -23,3 +23,5 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/ obj-$(CONFIG_INPUT_MISC) += misc/ obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o + +obj-$(CONFIG_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
drivers/input/xen-kbdfront.c new file +340 -0
340 lines not on this page · raw message
drivers/video/Kconfig +14 -0
@@ -1903,6 +1903,20 @@ config FB_VIRTUAL If unsure, say N. +config XEN_FBDEV_FRONTEND + tristate "Xen virtual frame buffer support" + depends on FB && XEN + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select FB_DEFERRED_IO + default y + help + This driver implements the front-end of the Xen virtual + frame buffer driver. It communicates with a back-end + in another domain. + source "drivers/video/omap/Kconfig" source "drivers/video/backlight/Kconfig"
drivers/video/Makefile +1 -0
@@ -113,6 +113,7 @@ obj-$(CONFIG_FB_PS3) += ps3fb.o obj-$(CONFIG_FB_SM501) += sm501fb.o obj-$(CONFIG_FB_XILINX) += xilinxfb.o obj-$(CONFIG_FB_OMAP) += omap/ +obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o # Platform or fallback drivers go here obj-$(CONFIG_FB_UVESA) += uvesafb.o
drivers/video/xen-fbfront.c new file +550 -0
550 lines not on this page · raw message
include/xen/interface/io/fbif.h new file +124 -0
124 lines not on this page · raw message
include/xen/interface/io/kbdif.h new file +114 -0
114 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/