fbdev: mm: Deferred IO support
Subsystems (4)
PATCH RESEND 8/9 fbdev: mm: Deferred IO support
From: Jaya Kumar <[email protected]>
This implements deferred IO support in fbdev. Deferred IO is a way to delay and repurpose IO. This implementation is done using mm's page_mkwrite and page_mkclean hooks in order to detect, delay and then rewrite IO. This functionality is used by hecubafb.
[adaplas]
This is useful for graphics hardware with no directly addressable/mappable framebuffer. Implementing this will allow the "framebuffer" to be accesible from user space via mmap().
---
Documentation/fb/deferred_io.txt | 75 +++++++++++++++++++++ drivers/video/Kconfig | 5 + drivers/video/Makefile | 1 drivers/video/fb_defio.c | 137 ++++++++++++++++++++++++++++++++++++++ include/linux/fb.h | 20 ++++++ mm/rmap.c | 1 6 files changed, 239 insertions(+), 0 deletions(-)
Documentation/fb/deferred_io.txt new file +75 -0
@@ -0,0 +1,75 @@ +Deferred IO +----------- + +Deferred IO is a way to delay and repurpose IO. It uses host memory as a +buffer and the MMU pagefault as a pretrigger for when to perform the device +IO. The following example may be a useful explaination of how one such setup +works: + +- userspace app like Xfbdev mmaps framebuffer +- deferred IO and driver sets up nopage and page_mkwrite handlers +- userspace app tries to write to mmaped vaddress +- we get pagefault and reach nopage handler +- nopage handler finds and returns physical page +- we get page_mkwrite where we add this page to a list +- schedule a workqueue task to be run after a delay +- app continues writing to that page with no additional cost. this is + the key benefit. +- the workqueue task comes in and mkcleans the pages on the list, then + completes the work associated with updating the framebuffer. this is + the real work talking to the device. +- app tries to write to the address (that has now been mkcleaned) +- get pagefault and the above sequence occurs again + +As can be seen from above, one benefit is roughly to allow bursty framebuffer +writes to occur at minimum cost. Then after some time when hopefully things +have gone quiet, we go and really update the framebuffer which would be +a relatively more expensive operation. + +For some types of nonvolatile high latency displays, the desired image is +the final image rather than the intermediate stages which is why it's okay +to not update for each write that is occuring. + +It may be the case that this is useful in other scenarios as well. Paul Mundt +has mentioned a case where it is beneficial to use the page count to decide +whether to coalesce and issue SG DMA or to do memory bursts. + +Another one may be if one has a device framebuffer that is in an usual format, +say diagonally shifting RGB, this may then be a mechanism for you to allow +apps to pretend to have a normal framebuffer but reswizzle for the device +framebuffer at vsync time based on the touched pagelist. + +How to use it: (for applications) +--------------------------------- +No changes needed. mmap the framebuffer like normal and just use it. + +How to use it: (for fbdev drivers) +---------------------------------- +The following example may be helpful. + +1. Setup your structure. Eg: + +static struct fb_deferred_io hecubafb_defio = { + .delay = HZ, + .deferred_io = hecubafb_dpy_deferred_io, +}; + +The delay is the minimum delay between when the page_mkwrite trigger occurs +and when the deferred_io callback is called. The deferred_io callback is +explained below. + +2. Setup your deferred IO callback. Eg: +static void hecubafb_dpy_deferred_io(struct fb_info *info, + struct list_head *pagelist) + +The deferred_io callback is where you would perform all your IO to the display +device. You receive the pagelist which is the list of pages that were written +to during the delay. You must not modify this list. This callback is called +from a workqueue. + +3. Call init + info->fbdefio = &hecubafb_defio; + fb_deferred_io_init(info); + +4. Call cleanup + fb_deferred_io_cleanup(info);
drivers/video/Kconfig +5 -0
@@ -92,6 +92,11 @@ config FB_CFB_IMAGEBLIT blitting. This is used by drivers that don't provide their own (accelerated) version. +config FB_DEFERRED_IO + bool + depends on FB + default y + config FB_SVGALIB tristate depends on FB
drivers/video/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_FB_CFB_IMAGEBLIT) += cfbimg obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_MACMODES) += macmodes.o obj-$(CONFIG_FB_DDC) += fb_ddc.o +obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o # Hardware specific drivers go first obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o
drivers/video/fb_defio.c new file +137 -0
137 lines not on this page · raw message
include/linux/fb.h +20 -0
@@ -561,6 +561,16 @@ struct fb_pixmap {void (*readio) (struct fb_info *info,void *dst,void __iomem *src,unsigned int size); }; +#ifdef CONFIG_FB_DEFERRED_IO +struct fb_deferred_io { +/* delay between mkwrite and deferred handler */ +unsigned long delay; +struct mutex lock;/* mutex that protects the page list */ +struct list_head pagelist;/* list of touched pages */ +/* callback */ +void (*deferred_io)(struct fb_info *info,struct list_head *pagelist); +}; +#endif /* * Frame buffer operations
@@ -778,6 +788,10 @@ #ifdef CONFIG_FB_BACKLIGHTstruct mutex bl_curve_mutex;u8 bl_curve[FB_BACKLIGHT_LEVELS ];#endif +#ifdef CONFIG_FB_DEFERRED_IO +struct delayed_work deferred_work; +struct fb_deferred_io *fbdefio; +#endif struct fb_ops *fbops;struct device *device;/* This is the parent */
@@ -913,6 +927,12 @@ static inline void __fb_pad_aligned_buff } } +#ifdef CONFIG_FB_DEFERRED_IO +/* drivers/video/fb_defio.c */ +extern void fb_deferred_io_init (struct fb_info *info); +extern void fb_deferred_io_cleanup (struct fb_info *info); +#endif +/* drivers/video/fbsysfs.c */ extern struct fb_info *framebuffer_alloc (size_t size,struct device *dev);extern void framebuffer_release (struct fb_info *info);
mm/rmap.c +1 -0
@@ -496,6 +496,7 @@ int page_mkclean(struct page *page)return ret; } +EXPORT_SYMBOL_GPL (page_mkclean);/** * page_set_anon_rmap - setup new anonymous rmap
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV