fbdev: Decouple deferred I/O from struct page
Subsystems (12)
Thomas Zimmermann
maintainerv4 cover fbdev: Decouple deferred I/O from struct page
Rework the fbdev deferred-I/O to not interfere with fields of struct page. All references from deferred-I/O code to fields in struct page are gone. The rsp state is held in a separate pageref structure.
v4:
* fix locking in fb_mmap() (Dan)
* fix commit-message style (Javier)
v3:
* rename pagelist to pagereflist (Sam)
* use pageref->offset over page->index (Javier)
v2:
* split off from a larger patchset [1]
[1] https://lore.kernel.org/dri-devel/[email protected]/
Thomas Zimmermann (5):
fbdev: Put mmap for deferred I/O into drivers
fbdev: Track deferred-I/O pages in pageref struct
fbdev: Refactor implementation of page_mkwrite
fbdev: Rename pagelist to pagereflist for deferred I/O
fbdev: Use pageref offset for deferred-I/O writeback
drivers/gpu/drm/drm_fb_helper.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 10 +- drivers/hid/hid-picolcd_fb.c | 3 +- drivers/staging/fbtft/fbtft-core.c | 21 ++- drivers/video/fbdev/broadsheetfb.c | 27 ++-- drivers/video/fbdev/core/fb_defio.c | 212 +++++++++++++++++-------- drivers/video/fbdev/core/fbmem.c | 22 +-- drivers/video/fbdev/hecubafb.c | 4 +- drivers/video/fbdev/hyperv_fb.c | 10 +- drivers/video/fbdev/metronomefb.c | 23 ++- drivers/video/fbdev/sh_mobile_lcdcfb.c | 27 ++-- drivers/video/fbdev/smscufx.c | 13 +- drivers/video/fbdev/ssd1307fb.c | 4 +- drivers/video/fbdev/udlfb.c | 18 +-- drivers/video/fbdev/xen-fbfront.c | 10 +- include/drm/drm_fb_helper.h | 3 +- include/linux/fb.h | 17 +- 17 files changed, 265 insertions(+), 174 deletions(-)
base-commit: 0e7deff6446a4ba2c75f499a0bfa80cd6a15c129
Signature · 1 line
2.36.0
Thomas Zimmermann
maintainerPATCH v4 1/5 fbdev: Put mmap for deferred I/O into drivers
The fbdev mmap function fb_mmap() unconditionally overrides the driver's implementation if deferred I/O has been activated. This makes it hard to implement mmap with anything but a vmalloc()'ed software buffer. That is specifically a problem for DRM, where video memory is maintained by a memory manager.
Leave the mmap handling to drivers and expect them to call the helper for deferred I/O by thmeselves.
v4:
* unlock mm_lock in fb_mmap() error path (Dan)
v3:
* fix warning if fb_mmap is missing (kernel test robot)
v2:
* print a helpful error message if the defio setup is incorrect (Javier)
--- drivers/gpu/drm/drm_fb_helper.c | 4 +++- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 1 + drivers/hid/hid-picolcd_fb.c | 1 + drivers/staging/fbtft/fbtft-core.c | 1 + drivers/video/fbdev/broadsheetfb.c | 1 + drivers/video/fbdev/core/fb_defio.c | 1 + drivers/video/fbdev/core/fbmem.c | 22 ++++++++++++---------- drivers/video/fbdev/hecubafb.c | 1 + drivers/video/fbdev/hyperv_fb.c | 1 + drivers/video/fbdev/metronomefb.c | 1 + drivers/video/fbdev/sh_mobile_lcdcfb.c | 6 ++++++ drivers/video/fbdev/smscufx.c | 3 +++ drivers/video/fbdev/ssd1307fb.c | 1 + drivers/video/fbdev/udlfb.c | 3 +++ drivers/video/fbdev/xen-fbfront.c | 1 + 15 files changed, 37 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +3 -1
@@ -2118,7 +2118,9 @@ static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) {struct drm_fb_helper *fb_helper = info->par; -if (fb_helper->dev->driver->gem_prime_mmap) +if (drm_fbdev_use_shadow_fb (fb_helper)) +return fb_deferred_io_mmap (info, vma); +else if (fb_helper->dev->driver->gem_prime_mmap)return fb_helper->dev->driver->gem_prime_mmap (fb_helper->buffer->gem, vma);else return -ENODEV ;
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +1 -0
@@ -619,6 +619,7 @@ static const struct fb_ops vmw_fb_ops = { .fb_imageblit = vmw_fb_imageblit, .fb_pan_display = vmw_fb_pan_display, .fb_blank = vmw_fb_blank, + .fb_mmap = fb_deferred_io_mmap, };int vmw_fb_init (struct vmw_private *vmw_priv)
drivers/hid/hid-picolcd_fb.c +1 -0
@@ -428,6 +428,7 @@ static const struct fb_ops picolcdfb_ops = { .fb_imageblit = picolcd_fb_imageblit, .fb_check_var = picolcd_fb_check_var, .fb_set_par = picolcd_set_par, + .fb_mmap = fb_deferred_io_mmap, };
drivers/staging/fbtft/fbtft-core.c +1 -0
@@ -652,6 +652,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbops->fb_imageblit = fbtft_fb_imageblit; fbops->fb_setcolreg = fbtft_fb_setcolreg; fbops->fb_blank = fbtft_fb_blank; + fbops->fb_mmap = fb_deferred_io_mmap; fbdefio->delay =HZ / fps; fbdefio->sort_pagelist = true;
drivers/video/fbdev/broadsheetfb.c +1 -0
@@ -1055,6 +1055,7 @@ static const struct fb_ops broadsheetfb_ops = { .fb_fillrect = broadsheetfb_fillrect, .fb_copyarea = broadsheetfb_copyarea, .fb_imageblit = broadsheetfb_imageblit, + .fb_mmap = fb_deferred_io_mmap, };static struct fb_deferred_io broadsheetfb_defio = {
drivers/video/fbdev/core/fb_defio.c +1 -0
@@ -181,6 +181,7 @@ int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) vma->vm_private_data = info;return 0 ; } +EXPORT_SYMBOL_GPL (fb_deferred_io_mmap);/* workqueue callback */ static void fb_deferred_io_work (struct work_struct *work)
drivers/video/fbdev/core/fbmem.c +12 -10
@@ -1334,7 +1334,6 @@ static int fb_mmap(struct file *file, struct vm_area_struct * vma) { struct fb_info *info = file_fb_info(file); -int (*fb_mmap_fn)(struct fb_info *info,struct vm_area_struct *vma);unsigned long mmio_pgoff;unsigned long start;u32 len;
@@ -1343,14 +1342,7 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)return -ENODEV ;mutex_lock (&info->mm_lock); - fb_mmap_fn = info->fbops->fb_mmap; - -#if IS_ENABLED (CONFIG_FB_DEFERRED_IO ) -if (info->fbdefio) - fb_mmap_fn = fb_deferred_io_mmap; -#endif - -if (fb_mmap_fn) { +if (info->fbops->fb_mmap) {int res;/*
@@ -1358,9 +1350,19 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)* SME protection is removed ahead of the call */ vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); - res =fb_mmap_fn (info, vma); + res = info->fbops->fb_mmap (info, vma);mutex_unlock (&info->mm_lock);return res; +#if IS_ENABLED (CONFIG_FB_DEFERRED_IO ) + } else if (info->fbdefio) { +/* +* FB deferred I/O wants you to handle mmap in your drivers. At a +* minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap(). +*/ +dev_warn_once (info->dev,"fbdev mmap not set up for deferred I/O.\n" ); +mutex_unlock (&info->mm_lock); +return -ENODEV ; +#endif }/*
drivers/video/fbdev/hecubafb.c +1 -0
@@ -204,6 +204,7 @@ static const struct fb_ops hecubafb_ops = { .fb_fillrect = hecubafb_fillrect, .fb_copyarea = hecubafb_copyarea, .fb_imageblit = hecubafb_imageblit, + .fb_mmap = fb_deferred_io_mmap, };static struct fb_deferred_io hecubafb_defio = {
drivers/video/fbdev/hyperv_fb.c +1 -0
@@ -909,6 +909,7 @@ static const struct fb_ops hvfb_ops = { .fb_copyarea = hvfb_cfb_copyarea, .fb_imageblit = hvfb_cfb_imageblit, .fb_blank = hvfb_blank, + .fb_mmap = fb_deferred_io_mmap, };
drivers/video/fbdev/metronomefb.c +1 -0
@@ -564,6 +564,7 @@ static const struct fb_ops metronomefb_ops = { .fb_fillrect = metronomefb_fillrect, .fb_copyarea = metronomefb_copyarea, .fb_imageblit = metronomefb_imageblit, + .fb_mmap = fb_deferred_io_mmap, };static struct fb_deferred_io metronomefb_defio = {
drivers/video/fbdev/sh_mobile_lcdcfb.c +6 -0
@@ -1483,6 +1483,9 @@ sh_mobile_lcdc_overlay_mmap(struct fb_info *info, struct vm_area_struct *vma) {struct sh_mobile_lcdc_overlay *ovl = info->par; +if (info->fbdefio) +return fb_deferred_io_mmap (info, vma); +return dma_mmap_coherent (ovl->channel->lcdc->dev, vma, ovl->fb_mem, ovl->dma_handle, ovl->fb_size); }
@@ -1957,6 +1960,9 @@ sh_mobile_lcdc_mmap(struct fb_info *info, struct vm_area_struct *vma) {struct sh_mobile_lcdc_chan *ch = info->par; +if (info->fbdefio) +return fb_deferred_io_mmap (info, vma); +return dma_mmap_coherent (ch->lcdc->dev, vma, ch->fb_mem, ch->dma_handle, ch->fb_size); }
drivers/video/fbdev/smscufx.c +3 -0
@@ -779,6 +779,9 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)unsigned long offset = vma->vm_pgoff <<PAGE_SHIFT ;unsigned long page, pos; +if (info->fbdefio) +return fb_deferred_io_mmap (info, vma); +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))return -EINVAL ;if (size > info->fix.smem_len)
drivers/video/fbdev/ssd1307fb.c +1 -0
@@ -368,6 +368,7 @@ static const struct fb_ops ssd1307fb_ops = { .fb_fillrect = ssd1307fb_fillrect, .fb_copyarea = ssd1307fb_copyarea, .fb_imageblit = ssd1307fb_imageblit, + .fb_mmap = fb_deferred_io_mmap, }; static void ssd1307fb_deferred_io(struct fb_info *info,
drivers/video/fbdev/udlfb.c +3 -0
@@ -326,6 +326,9 @@ static int dlfb_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)unsigned long offset = vma->vm_pgoff <<PAGE_SHIFT ;unsigned long page, pos; +if (info->fbdefio) +return fb_deferred_io_mmap (info, vma); +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))return -EINVAL ;if (size > info->fix.smem_len)
drivers/video/fbdev/xen-fbfront.c +1 -0
@@ -338,6 +338,7 @@ static const struct fb_ops xenfb_fb_ops = { .fb_imageblit = xenfb_imageblit, .fb_check_var = xenfb_check_var, .fb_set_par = xenfb_set_par, + .fb_mmap = fb_deferred_io_mmap, };static irqreturn_t xenfb_event_handler (int rq,void *dev_id)
Signature · 1 line
2.36.0
Thomas Zimmermann
maintainerPATCH v4 2/5 fbdev: Track deferred-I/O pages in pageref struct
In reply to Thomas ZimmermannStore the per-page state for fbdev's deferred I/O in struct fb_deferred_io_pageref. Maintain a list of pagerefs for the pages that have to be written back to video memory. Update all affected drivers.
As with pages before, fbdev acquires a pageref when an mmaped page of the framebuffer is being written to. It holds the pageref in a list of all currently written pagerefs until it flushes the written pages to video memory. Writeback occurs periodically. After writeback fbdev releases all pagerefs and builds up a new dirty list until the next writeback occurs.
Using pagerefs has a number of benefits.
For pages of the framebuffer, the deferred I/O code used struct page.lru as an entry into the list of dirty pages. The lru field is owned by the page cache, which makes deferred I/O incompatible with some memory pages (e.g., most notably DRM's GEM SHMEM allocator). struct fb_deferred_io_pageref now provides an entry into a list of dirty framebuffer pages, freeing lru for use with the page cache.
Drivers also assumed that struct page.index is the page offset into the framebuffer. This is not true for DRM buffers, which are located at various offset within a mapped area. struct fb_deferred_io_pageref explicitly stores an offset into the framebuffer. struct page.index is now only the page offset into the mapped area.
These changes will allow DRM to use fbdev deferred I/O without an intermediate shadow buffer.
v3:
* use pageref->offset for sorting
* fix grammar in comment
v2:
* minor fixes in commit message
--- drivers/gpu/drm/drm_fb_helper.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 5 +- drivers/staging/fbtft/fbtft-core.c | 5 +- drivers/video/fbdev/broadsheetfb.c | 5 +- drivers/video/fbdev/core/fb_defio.c | 156 ++++++++++++++++--------- drivers/video/fbdev/hyperv_fb.c | 5 +- drivers/video/fbdev/metronomefb.c | 5 +- drivers/video/fbdev/sh_mobile_lcdcfb.c | 6 +- drivers/video/fbdev/smscufx.c | 5 +- drivers/video/fbdev/udlfb.c | 5 +- drivers/video/fbdev/xen-fbfront.c | 5 +- include/linux/fb.h | 11 +- 12 files changed, 145 insertions(+), 74 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +3 -3
@@ -717,13 +717,13 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagelist) {unsigned long start, end, min, max; -struct page *page; +struct fb_deferred_io_pageref *pageref;struct drm_rect damage_area; min =ULONG_MAX ; max =0 ; -list_for_each_entry (page, pagelist, lru) { - start = page->index <<PAGE_SHIFT ; +list_for_each_entry (pageref, pagelist, list) { + start = pageref->offset; end = start +PAGE_SIZE ; min =min (min, start); max =max (max, end);
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +3 -2
@@ -322,12 +322,13 @@ static void vmw_deferred_io(struct fb_info *info,struct vmw_fb_par *par = info->par;unsigned long start, end, min, max;unsigned long flags; -struct page *page; +struct fb_deferred_io_pageref *pageref;int y1, y2; min =ULONG_MAX ; max =0 ; -list_for_each_entry (page, pagelist, lru) { +list_for_each_entry (pageref, pagelist, list) { +struct page *page = pageref->page; start = page->index <<PAGE_SHIFT ; end = start +PAGE_SIZE -1 ; min =min (min, start);
drivers/staging/fbtft/fbtft-core.c +3 -2
@@ -326,7 +326,7 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist) {struct fbtft_par *par = info->par;unsigned int dirty_lines_start, dirty_lines_end; -struct page *page; +struct fb_deferred_io_pageref *pageref;unsigned long index;unsigned int y_low =0 , y_high =0 ;int count =0 ;
@@ -340,7 +340,8 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist)spin_unlock (&par->dirty_lock);/* Mark display lines as dirty */ -list_for_each_entry (page, pagelist, lru) { +list_for_each_entry (pageref, pagelist, list) { +struct page *page = pageref->page; count++; index = page->index <<PAGE_SHIFT ; y_low = index / info->fix.line_length;
drivers/video/fbdev/broadsheetfb.c +3 -2
@@ -934,7 +934,7 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info, {u16 y1 =0 , h =0 ;int prev_index =-1 ; -struct page *cur; +struct fb_deferred_io_pageref *pageref;struct fb_deferred_io *fbdefio = info->fbdefio;int h_inc;u16 yres = info->var.yres;
@@ -944,7 +944,8 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info, h_inc =DIV_ROUND_UP (PAGE_SIZE , xres);/* walk the written page list and swizzle the data */ -list_for_each_entry (cur, &fbdefio->pagelist, lru) { +list_for_each_entry (pageref, &fbdefio->pagelist, list) { +struct page *cur = pageref->page;if (prev_index <0 ) {/* just starting so assign first page */ y1 = (cur->index <<PAGE_SHIFT ) / xres;
drivers/video/fbdev/core/fb_defio.c +104 -52
228 lines not on this page · raw message
drivers/video/fbdev/hyperv_fb.c +3 -2
@@ -424,7 +424,7 @@ static void synthvid_deferred_io(struct fb_info *p, struct list_head *pagelist) {struct hvfb_par *par = p->par; -struct page *page; +struct fb_deferred_io_pageref *pageref;unsigned long start, end;int y1, y2, miny, maxy;
@@ -437,7 +437,8 @@ static void synthvid_deferred_io(struct fb_info *p,* in synthvid_update function by clamping the y2 * value to yres. */ -list_for_each_entry (page, pagelist, lru) { +list_for_each_entry (pageref, pagelist, list) { +struct page *page = pageref->page; start = page->index <<PAGE_SHIFT ; end = start +PAGE_SIZE -1 ; y1 = start / p->fix.line_length;
drivers/video/fbdev/metronomefb.c +3 -2
@@ -469,12 +469,13 @@ static void metronomefb_dpy_deferred_io(struct fb_info *info, struct list_head *pagelist) {u16 cksum; -struct page *cur; +struct fb_deferred_io_pageref *pageref;struct fb_deferred_io *fbdefio = info->fbdefio;struct metronomefb_par *par = info->par;/* walk the written page list and swizzle the data */ -list_for_each_entry (cur, &fbdefio->pagelist, lru) { +list_for_each_entry (pageref, &fbdefio->pagelist, list) { +struct page *cur = pageref->page; cksum =metronomefb_dpy_update_page (par, (cur->index <<PAGE_SHIFT )); par->metromem_img_csum -= par->csum_table[cur->index];
drivers/video/fbdev/sh_mobile_lcdcfb.c +4 -2
@@ -440,13 +440,15 @@ static int sh_mobile_lcdc_sginit(struct fb_info *info, {struct sh_mobile_lcdc_chan *ch = info->par;unsigned int nr_pages_max = ch->fb_size >>PAGE_SHIFT ; -struct page *page; +struct fb_deferred_io_pageref *pageref;int nr_pages =0 ;sg_init_table (ch->sglist, nr_pages_max); -list_for_each_entry (page, pagelist, lru) +list_for_each_entry (pageref, pagelist, list) { +struct page *page = pageref->page;sg_set_page (&ch->sglist[nr_pages++], page,PAGE_SIZE ,0 ); + }return nr_pages; }
drivers/video/fbdev/smscufx.c +3 -2
@@ -958,7 +958,7 @@ static void ufx_ops_fillrect(struct fb_info *info,static void ufx_dpy_deferred_io (struct fb_info *info,struct list_head *pagelist) { -struct page *cur; +struct fb_deferred_io_pageref *pageref;struct fb_deferred_io *fbdefio = info->fbdefio;struct ufx_data *dev = info->par;
@@ -969,9 +969,10 @@ static void ufx_dpy_deferred_io(struct fb_info *info,return ;/* walk the written page list and render each to device */ -list_for_each_entry (cur, &fbdefio->pagelist, lru) { +list_for_each_entry (pageref, &fbdefio->pagelist, list) {/* create a rectangle of full screen width that encloses the * entire dirty framebuffer page */ +struct page *cur = pageref->page;const int x =0 ;const int width = dev->info->var.xres;const int y = (cur->index <<PAGE_SHIFT ) / (width *2 );
drivers/video/fbdev/udlfb.c +3 -2
@@ -784,7 +784,7 @@ static void dlfb_ops_fillrect(struct fb_info *info,static void dlfb_dpy_deferred_io (struct fb_info *info,struct list_head *pagelist) { -struct page *cur; +struct fb_deferred_io_pageref *pageref;struct fb_deferred_io *fbdefio = info->fbdefio;struct dlfb_data *dlfb = info->par;struct urb *urb;
@@ -811,7 +811,8 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, cmd = urb->transfer_buffer;/* walk the written page list and render each to device */ -list_for_each_entry (cur, &fbdefio->pagelist, lru) { +list_for_each_entry (pageref, &fbdefio->pagelist, list) { +struct page *cur = pageref->page; if (dlfb_render_hline(dlfb, &urb, (char *) info->fix.smem_start, &cmd, cur->index << PAGE_SHIFT,
drivers/video/fbdev/xen-fbfront.c +3 -2
@@ -185,13 +185,14 @@ static void xenfb_deferred_io(struct fb_info *fb_info, struct list_head *pagelist) {struct xenfb_info *info = fb_info->par; -struct page *page; +struct fb_deferred_io_pageref *pageref;unsigned long beg, end;int y1, y2, miny, maxy; miny =INT_MAX ; maxy =0 ; -list_for_each_entry (page, pagelist, lru) { +list_for_each_entry (pageref, pagelist, list) { +struct page *page = pageref->page; beg = page->index <<PAGE_SHIFT ; end = beg +PAGE_SIZE -1 ; y1 = beg / fb_info->fix.line_length;
include/linux/fb.h +10 -1
@@ -201,6 +201,13 @@ struct fb_pixmap { }; #ifdef CONFIG_FB_DEFERRED_IO +struct fb_deferred_io_pageref { + struct page *page; + unsigned long offset; + /* private */ + struct list_head list; +}; + struct fb_deferred_io { /* delay between mkwrite and deferred handler */ unsigned long delay;
@@ -468,6 +475,8 @@ struct fb_info {#endif #ifdef CONFIG_FB_DEFERRED_IO struct delayed_work deferred_work; +unsigned long npagerefs; +struct fb_deferred_io_pageref *pagerefs;struct fb_deferred_io *fbdefio;#endif
@@ -661,7 +670,7 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,/* drivers/video/fb_defio.c */ int fb_deferred_io_mmap (struct fb_info *info,struct vm_area_struct *vma); -extern void fb_deferred_io_init (struct fb_info *info); +extern int fb_deferred_io_init (struct fb_info *info);extern void fb_deferred_io_open (struct fb_info *info,struct inode *inode,struct file *file);
Signature · 1 line
2.36.0
Thomas Zimmermann
maintainerPATCH v4 3/5 fbdev: Refactor implementation of page_mkwrite
In reply to Thomas ZimmermannRefactor the page-write handler for deferred I/O. Drivers use the function to let fbdev track written pages of mmap'ed framebuffer memory.
v3:
* keep locking within track-pages function for readability (Sam)
v2:
* don't export the helper until we have an external caller
--- drivers/video/fbdev/core/fb_defio.c | 53 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-)
drivers/video/fbdev/core/fb_defio.c +38 -15
@@ -143,26 +143,17 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy }EXPORT_SYMBOL_GPL (fb_deferred_io_fsync); -/* vm_ops->page_mkwrite handler */ -static vm_fault_t fb_deferred_io_mkwrite (struct vm_fault *vmf) +/* +* Adds a page to the dirty list. Call this from struct +* vm_operations_struct.page_mkwrite. +*/ +static vm_fault_t fb_deferred_io_track_page (struct fb_info *info,unsigned long offset, +struct page *page) { -struct page *page = vmf->page; -struct fb_info *info = vmf->vma->vm_private_data;struct fb_deferred_io *fbdefio = info->fbdefio;struct fb_deferred_io_pageref *pageref; -unsigned long offset;vm_fault_t ret; - offset = (vmf->address - vmf->vma->vm_start); - -/* this is a callback we get when userspace first tries to -write to the page. we schedule a workqueue. that workqueue -will eventually mkclean the touched pages and execute the -deferred framebuffer IO. then if userspace touches a page -again, we repeat the same scheme */ - -file_update_time (vmf->vma->vm_file); -/* protect against the workqueue changing the page list */ mutex_lock (&fbdefio->lock);
@@ -197,6 +188,38 @@ static vm_fault_t fb_deferred_io_mkwrite(struct vm_fault *vmf)return ret; } +/* +* fb_deferred_io_page_mkwrite - Mark a page as written for deferred I/O +* @fb_info: The fbdev info structure +* @vmf: The VM fault +* +* This is a callback we get when userspace first tries to +* write to the page. We schedule a workqueue. That workqueue +* will eventually mkclean the touched pages and execute the +* deferred framebuffer IO. Then if userspace touches a page +* again, we repeat the same scheme. +* +* Returns: +* VM_FAULT_LOCKED on success, or a VM_FAULT error otherwise. +*/ +static vm_fault_t fb_deferred_io_page_mkwrite (struct fb_info *info,struct vm_fault *vmf) +{ +unsigned long offset = vmf->address - vmf->vma->vm_start; +struct page *page = vmf->page; + +file_update_time (vmf->vma->vm_file); + +return fb_deferred_io_track_page (info, offset, page); +} + +/* vm_ops->page_mkwrite handler */ +static vm_fault_t fb_deferred_io_mkwrite (struct vm_fault *vmf) +{ +struct fb_info *info = vmf->vma->vm_private_data; + +return fb_deferred_io_page_mkwrite (info, vmf); +} +static const struct vm_operations_struct fb_deferred_io_vm_ops = { .fault = fb_deferred_io_fault, .page_mkwrite = fb_deferred_io_mkwrite,
Signature · 1 line
2.36.0
Thomas Zimmermann
maintainerPATCH v4 4/5 fbdev: Rename pagelist to pagereflist for deferred I/O
In reply to Thomas ZimmermannRename various instances of pagelist to pagereflist. The list now stores pageref structures, so the new name is more appropriate.
In their write-back helpers, several fbdev drivers refer to the pageref list in struct fb_deferred_io instead of using the one supplied as argument to the function. Convert them over to the supplied one. It's the same instance, so no change of behavior occurs.
v4:
* fix commit message (Javier)
--- drivers/gpu/drm/drm_fb_helper.c | 7 +++---- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 5 ++--- drivers/hid/hid-picolcd_fb.c | 2 +- drivers/staging/fbtft/fbtft-core.c | 10 +++++----- drivers/video/fbdev/broadsheetfb.c | 12 +++++------- drivers/video/fbdev/core/fb_defio.c | 18 +++++++++--------- drivers/video/fbdev/hecubafb.c | 3 +-- drivers/video/fbdev/hyperv_fb.c | 5 ++--- drivers/video/fbdev/metronomefb.c | 12 +++++------- drivers/video/fbdev/sh_mobile_lcdcfb.c | 16 +++++++--------- drivers/video/fbdev/smscufx.c | 8 +++----- drivers/video/fbdev/ssd1307fb.c | 3 +-- drivers/video/fbdev/udlfb.c | 8 +++----- drivers/video/fbdev/xen-fbfront.c | 5 ++--- include/drm/drm_fb_helper.h | 3 +-- include/linux/fb.h | 6 +++--- 16 files changed, 53 insertions(+), 70 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +3 -4
@@ -708,13 +708,12 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,/** * drm_fb_helper_deferred_io() - fbdev deferred_io callback function * @info: fb_info struct pointer -* @pagelist: list of mmap framebuffer pages that have to be flushed +* @pagereflist: list of mmap framebuffer pages that have to be flushed * * This function is used as the &fb_deferred_io.deferred_io * callback function for flushing the fbdev mmap writes. */ -void drm_fb_helper_deferred_io (struct fb_info *info, -struct list_head *pagelist) +void drm_fb_helper_deferred_io (struct fb_info *info,struct list_head *pagereflist) {unsigned long start, end, min, max;struct fb_deferred_io_pageref *pageref;
@@ -722,7 +721,7 @@ void drm_fb_helper_deferred_io(struct fb_info *info, min =ULONG_MAX ; max =0 ; -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) { start = pageref->offset; end = start +PAGE_SIZE ; min =min (min, start);
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +2 -3
@@ -316,8 +316,7 @@ static int vmw_fb_pan_display(struct fb_var_screeninfo *var,return 0 ; } -static void vmw_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void vmw_deferred_io (struct fb_info *info,struct list_head *pagereflist) {struct vmw_fb_par *par = info->par;unsigned long start, end, min, max;
@@ -327,7 +326,7 @@ static void vmw_deferred_io(struct fb_info *info, min =ULONG_MAX ; max =0 ; -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *page = pageref->page; start = page->index <<PAGE_SHIFT ; end = start +PAGE_SIZE -1 ;
drivers/hid/hid-picolcd_fb.c +1 -1
@@ -433,7 +433,7 @@ static const struct fb_ops picolcdfb_ops = {/* Callback from deferred IO workqueue */ -static void picolcd_fb_deferred_io (struct fb_info *info,struct list_head *pagelist) +static void picolcd_fb_deferred_io (struct fb_info *info,struct list_head *pagereflist) {picolcd_fb_update (info); }
drivers/staging/fbtft/fbtft-core.c +5 -5
@@ -322,7 +322,7 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height)schedule_delayed_work (&info->deferred_work, fbdefio->delay); } -static void fbtft_deferred_io (struct fb_info *info,struct list_head *pagelist) +static void fbtft_deferred_io (struct fb_info *info,struct list_head *pagereflist) {struct fbtft_par *par = info->par;unsigned int dirty_lines_start, dirty_lines_end;
@@ -340,7 +340,7 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist)spin_unlock (&par->dirty_lock);/* Mark display lines as dirty */ -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *page = pageref->page; count++; index = page->index <<PAGE_SHIFT ;
@@ -655,9 +655,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbops->fb_blank = fbtft_fb_blank; fbops->fb_mmap = fb_deferred_io_mmap; - fbdefio->delay =HZ / fps; - fbdefio->sort_pagelist = true; - fbdefio->deferred_io = fbtft_deferred_io; + fbdefio->delay =HZ / fps; + fbdefio->sort_pagereflist = true; + fbdefio->deferred_io = fbtft_deferred_io;fb_deferred_io_init (info);snprintf (info->fix.id,sizeof (info->fix.id),"%s" , dev->driver->name);
drivers/video/fbdev/broadsheetfb.c +5 -7
@@ -929,13 +929,11 @@ static void broadsheetfb_dpy_update(struct broadsheetfb_par *par) }/* this is called back from the deferred io workqueue */ -static void broadsheetfb_dpy_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void broadsheetfb_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) {u16 y1 =0 , h =0 ;int prev_index =-1 ;struct fb_deferred_io_pageref *pageref; -struct fb_deferred_io *fbdefio = info->fbdefio;int h_inc;u16 yres = info->var.yres;u16 xres = info->var.xres;
@@ -944,7 +942,7 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info, h_inc =DIV_ROUND_UP (PAGE_SIZE , xres);/* walk the written page list and swizzle the data */ -list_for_each_entry (pageref, &fbdefio->pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *cur = pageref->page;if (prev_index <0 ) {/* just starting so assign first page */
@@ -1060,9 +1058,9 @@ static const struct fb_ops broadsheetfb_ops = { };static struct fb_deferred_io broadsheetfb_defio = { - .delay =HZ /4 , - .sort_pagelist = true, - .deferred_io = broadsheetfb_dpy_deferred_io, + .delay =HZ /4 , + .sort_pagereflist = true, + .deferred_io = broadsheetfb_dpy_deferred_io, };static int broadsheetfb_probe (struct platform_device *dev)
drivers/video/fbdev/core/fb_defio.c +9 -9
@@ -41,7 +41,7 @@ static struct fb_deferred_io_pageref *fb_deferred_io_pageref_get(struct fb_info struct page *page) {struct fb_deferred_io *fbdefio = info->fbdefio; -struct list_head *pos = &fbdefio->pagelist; +struct list_head *pos = &fbdefio->pagereflist;unsigned long pgoff = offset >>PAGE_SHIFT ;struct fb_deferred_io_pageref *pageref, *cur;
@@ -63,7 +63,7 @@ static struct fb_deferred_io_pageref *fb_deferred_io_pageref_get(struct fb_info pageref->page = page; pageref->offset = pgoff <<PAGE_SHIFT ; -if (unlikely (fbdefio->sort_pagelist)) { +if (unlikely (fbdefio->sort_pagereflist)) {/* * We loop through the list of pagerefs before adding in * order to keep the pagerefs sorted. This has significant
@@ -71,7 +71,7 @@ static struct fb_deferred_io_pageref *fb_deferred_io_pageref_get(struct fb_info* pages. If possible, drivers should try to work with * unsorted page lists instead. */ -list_for_each_entry (cur, &info->fbdefio->pagelist, list) { +list_for_each_entry (cur, &fbdefio->pagereflist, list) {if (cur->offset > pageref->offset)break ; }
@@ -158,7 +158,7 @@ static vm_fault_t fb_deferred_io_track_page(struct fb_info *info, unsigned longmutex_lock (&fbdefio->lock);/* first write in this cycle, notify the driver */ -if (fbdefio->first_io &&list_empty (&fbdefio->pagelist)) +if (fbdefio->first_io &&list_empty (&fbdefio->pagereflist)) fbdefio->first_io (info); pageref =fb_deferred_io_pageref_get (info, offset, page);
@@ -249,18 +249,18 @@ static void fb_deferred_io_work(struct work_struct *work)/* here we mkclean the pages, then do all deferred IO */ mutex_lock (&fbdefio->lock); -list_for_each_entry (pageref, &fbdefio->pagelist, list) { +list_for_each_entry (pageref, &fbdefio->pagereflist, list) {struct page *cur = pageref->page;lock_page (cur);page_mkclean (cur);unlock_page (cur); } -/* driver's callback with pagelist */ - fbdefio->deferred_io (info, &fbdefio->pagelist); +/* driver's callback with pagereflist */ + fbdefio->deferred_io (info, &fbdefio->pagereflist);/* clear the list */ -list_for_each_entry_safe (pageref, next, &fbdefio->pagelist, list) +list_for_each_entry_safe (pageref, next, &fbdefio->pagereflist, list)fb_deferred_io_pageref_put (pageref, info);mutex_unlock (&fbdefio->lock);
@@ -280,7 +280,7 @@ int fb_deferred_io_init(struct fb_info *info)mutex_init (&fbdefio->lock);INIT_DELAYED_WORK (&info->deferred_work, fb_deferred_io_work); -INIT_LIST_HEAD (&fbdefio->pagelist); +INIT_LIST_HEAD (&fbdefio->pagereflist);if (fbdefio->delay ==0 )/* set a default of 1 s */ fbdefio->delay =HZ ;
drivers/video/fbdev/hecubafb.c +1 -2
@@ -115,8 +115,7 @@ static void hecubafb_dpy_update(struct hecubafb_par *par) }/* this is called back from the deferred io workqueue */ -static void hecubafb_dpy_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void hecubafb_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) {hecubafb_dpy_update (info->par); }
drivers/video/fbdev/hyperv_fb.c +2 -3
@@ -420,8 +420,7 @@ static void hvfb_docopy(struct hvfb_par *par, }/* Deferred IO callback */ -static void synthvid_deferred_io (struct fb_info *p, -struct list_head *pagelist) +static void synthvid_deferred_io (struct fb_info *p,struct list_head *pagereflist) {struct hvfb_par *par = p->par;struct fb_deferred_io_pageref *pageref;
@@ -437,7 +436,7 @@ static void synthvid_deferred_io(struct fb_info *p,* in synthvid_update function by clamping the y2 * value to yres. */ -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *page = pageref->page; start = page->index <<PAGE_SHIFT ; end = start +PAGE_SIZE -1 ;
drivers/video/fbdev/metronomefb.c +5 -7
@@ -465,16 +465,14 @@ static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index) }/* this is called back from the deferred io workqueue */ -static void metronomefb_dpy_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void metronomefb_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) {u16 cksum;struct fb_deferred_io_pageref *pageref; -struct fb_deferred_io *fbdefio = info->fbdefio;struct metronomefb_par *par = info->par;/* walk the written page list and swizzle the data */ -list_for_each_entry (pageref, &fbdefio->pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *cur = pageref->page; cksum =metronomefb_dpy_update_page (par, (cur->index <<PAGE_SHIFT ));
@@ -569,9 +567,9 @@ static const struct fb_ops metronomefb_ops = { };static struct fb_deferred_io metronomefb_defio = { - .delay =HZ , - .sort_pagelist = true, - .deferred_io = metronomefb_dpy_deferred_io, + .delay =HZ , + .sort_pagereflist = true, + .deferred_io = metronomefb_dpy_deferred_io, };static int metronomefb_probe (struct platform_device *dev)
drivers/video/fbdev/sh_mobile_lcdcfb.c +7 -9
@@ -435,8 +435,7 @@ static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { .read_data = lcdc_sys_read_data, }; -static int sh_mobile_lcdc_sginit (struct fb_info *info, -struct list_head *pagelist) +static int sh_mobile_lcdc_sginit (struct fb_info *info,struct list_head *pagereflist) {struct sh_mobile_lcdc_chan *ch = info->par;unsigned int nr_pages_max = ch->fb_size >>PAGE_SHIFT ;
@@ -445,7 +444,7 @@ static int sh_mobile_lcdc_sginit(struct fb_info *info,sg_init_table (ch->sglist, nr_pages_max); -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *page = pageref->page;sg_set_page (&ch->sglist[nr_pages++], page,PAGE_SIZE ,0 ); }
@@ -453,8 +452,7 @@ static int sh_mobile_lcdc_sginit(struct fb_info *info,return nr_pages; } -static void sh_mobile_lcdc_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void sh_mobile_lcdc_deferred_io (struct fb_info *info,struct list_head *pagereflist) {struct sh_mobile_lcdc_chan *ch = info->par;const struct sh_mobile_lcdc_panel_cfg *panel = &ch->cfg->panel_cfg;
@@ -463,7 +461,7 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,sh_mobile_lcdc_clk_on (ch->lcdc);/* -* It's possible to get here without anything on the pagelist via +* It's possible to get here without anything on the pagereflist via * sh_mobile_lcdc_deferred_io_touch() or via a userspace fsync() * invocation. In the former case, the acceleration routines are * stepped in to when using the framebuffer console causing the
@@ -473,12 +471,12 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,* acceleration routines have their own methods for writing in * that still need to be updated. * -* The fsync() and empty pagelist case could be optimized for, +* The fsync() and empty pagereflist case could be optimized for, * but we don't bother, as any application exhibiting such * behaviour is fundamentally broken anyways. */ -if (!list_empty (pagelist)) { -unsigned int nr_pages =sh_mobile_lcdc_sginit (info, pagelist); +if (!list_empty (pagereflist)) { +unsigned int nr_pages =sh_mobile_lcdc_sginit (info, pagereflist);/* trigger panel update */ dma_map_sg (ch->lcdc->dev, ch->sglist, nr_pages,DMA_TO_DEVICE );
drivers/video/fbdev/smscufx.c +3 -5
@@ -955,12 +955,10 @@ static void ufx_ops_fillrect(struct fb_info *info,* Touching ANY framebuffer memory that triggers a page fault * in fb_defio will cause a deadlock, when it also tries to * grab the same mutex. */ -static void ufx_dpy_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void ufx_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) { -struct fb_deferred_io_pageref *pageref; -struct fb_deferred_io *fbdefio = info->fbdefio;struct ufx_data *dev = info->par; +struct fb_deferred_io_pageref *pageref;if (!fb_defio)return ;
@@ -969,7 +967,7 @@ static void ufx_dpy_deferred_io(struct fb_info *info,return ;/* walk the written page list and render each to device */ -list_for_each_entry (pageref, &fbdefio->pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {/* create a rectangle of full screen width that encloses the * entire dirty framebuffer page */ struct page *cur = pageref->page;
drivers/video/fbdev/ssd1307fb.c +1 -2
@@ -371,8 +371,7 @@ static const struct fb_ops ssd1307fb_ops = { .fb_mmap = fb_deferred_io_mmap, }; -static void ssd1307fb_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void ssd1307fb_deferred_io (struct fb_info *info,struct list_head *pagereflist) {ssd1307fb_update_display (info->par); }
drivers/video/fbdev/udlfb.c +3 -5
@@ -781,11 +781,9 @@ static void dlfb_ops_fillrect(struct fb_info *info,* in fb_defio will cause a deadlock, when it also tries to * grab the same mutex. */ -static void dlfb_dpy_deferred_io (struct fb_info *info, -struct list_head *pagelist) +static void dlfb_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) {struct fb_deferred_io_pageref *pageref; -struct fb_deferred_io *fbdefio = info->fbdefio;struct dlfb_data *dlfb = info->par;struct urb *urb;char *cmd;
@@ -811,7 +809,7 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, cmd = urb->transfer_buffer;/* walk the written page list and render each to device */ -list_for_each_entry (pageref, &fbdefio->pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *cur = pageref->page; if (dlfb_render_hline(dlfb, &urb, (char *) info->fix.smem_start,
@@ -984,7 +982,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)if (fbdefio) { fbdefio->delay =DL_DEFIO_WRITE_DELAY ; - fbdefio->sort_pagelist = true; + fbdefio->sort_pagereflist = true; fbdefio->deferred_io = dlfb_dpy_deferred_io; }
drivers/video/fbdev/xen-fbfront.c +2 -3
@@ -181,8 +181,7 @@ static void xenfb_refresh(struct xenfb_info *info,xenfb_do_update (info, x1, y1, x2 - x1 +1 , y2 - y1 +1 ); } -static void xenfb_deferred_io (struct fb_info *fb_info, -struct list_head *pagelist) +static void xenfb_deferred_io (struct fb_info *fb_info,struct list_head *pagereflist) {struct xenfb_info *info = fb_info->par;struct fb_deferred_io_pageref *pageref;
@@ -191,7 +190,7 @@ static void xenfb_deferred_io(struct fb_info *fb_info, miny =INT_MAX ; maxy =0 ; -list_for_each_entry (pageref, pagelist, list) { +list_for_each_entry (pageref, pagereflist, list) {struct page *page = pageref->page; beg = page->index <<PAGE_SHIFT ; end = beg +PAGE_SIZE -1 ;
include/drm/drm_fb_helper.h +1 -2
@@ -229,8 +229,7 @@ void drm_fb_helper_fill_info(struct fb_info *info,struct drm_fb_helper *fb_helper, struct drm_fb_helper_surface_size *sizes); -void drm_fb_helper_deferred_io (struct fb_info *info, -struct list_head *pagelist); +void drm_fb_helper_deferred_io (struct fb_info *info,struct list_head *pagereflist);ssize_t drm_fb_helper_sys_read (struct fb_info *info,char __user *buf,size_t count,loff_t *ppos);
include/linux/fb.h +3 -3
@@ -211,9 +211,9 @@ struct fb_deferred_io_pageref {struct fb_deferred_io {/* delay between mkwrite and deferred handler */ unsigned long delay; -bool sort_pagelist;/* sort pagelist by offset */ -struct mutex lock;/* mutex that protects the page list */ -struct list_head pagelist;/* list of touched pages */ +bool sort_pagereflist;/* sort pagelist by offset */ +struct mutex lock;/* mutex that protects the pageref list */ +struct list_head pagereflist;/* list of pagerefs for touched pages */ /* callback */ void (*first_io)(struct fb_info *info);void (*deferred_io)(struct fb_info *info,struct list_head *pagelist);
Signature · 1 line
2.36.0
Thomas Zimmermann
maintainerPATCH v4 5/5 fbdev: Use pageref offset for deferred-I/O writeback
In reply to Thomas ZimmermannUse pageref->offset instead of page->index for deferred-I/O writeback where appropriate. Distinguishes between file-mapping offset and video- memory offset. While at it, also remove unnecessary references to struct page.
Fbdev's deferred-I/O code uses the two related page->index and pageref->offset. The former is the page offset in the mapped file, the latter is the byte offset in the video memory (or fbdev screen buffer). It's the same value for fbdev drivers, but for DRM the values can be different. Because GEM buffer objects are mapped at an offset in the DRM device file, page->index has this offset added to it as well. We currently don't hit this case in DRM, because all affected mappings of GEM memory are performed with an internal, intermediate shadow buffer.
The value of page->index is required by page_mkclean(), which we call to reset the mappings during the writeback phase of the deferred I/O. The value of pageref->offset is for conveniently getting an offset into video memory in fb helpers.
v4:
* fix commit message (Javier)
--- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 3 +-- drivers/staging/fbtft/fbtft-core.c | 9 +++------ drivers/video/fbdev/broadsheetfb.c | 13 ++++++------- drivers/video/fbdev/hyperv_fb.c | 3 +-- drivers/video/fbdev/metronomefb.c | 9 ++++----- drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +-- drivers/video/fbdev/smscufx.c | 3 +-- drivers/video/fbdev/udlfb.c | 6 ++---- drivers/video/fbdev/xen-fbfront.c | 3 +-- 9 files changed, 20 insertions(+), 32 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +1 -2
@@ -327,8 +327,7 @@ static void vmw_deferred_io(struct fb_info *info, struct list_head *pagereflist) min =ULONG_MAX ; max =0 ;list_for_each_entry (pageref, pagereflist, list) { -struct page *page = pageref->page; - start = page->index <<PAGE_SHIFT ; + start = pageref->offset; end = start +PAGE_SIZE -1 ; min =min (min, start); max =max (max, end);
drivers/staging/fbtft/fbtft-core.c +3 -6
@@ -327,7 +327,6 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflisstruct fbtft_par *par = info->par;unsigned int dirty_lines_start, dirty_lines_end;struct fb_deferred_io_pageref *pageref; -unsigned long index;unsigned int y_low =0 , y_high =0 ;int count =0 ;
@@ -341,14 +340,12 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflis/* Mark display lines as dirty */ list_for_each_entry (pageref, pagereflist, list) { -struct page *page = pageref->page; count++; - index = page->index <<PAGE_SHIFT ; - y_low = index / info->fix.line_length; - y_high = (index +PAGE_SIZE -1 ) / info->fix.line_length; + y_low = pageref->offset / info->fix.line_length; + y_high = (pageref->offset +PAGE_SIZE -1 ) / info->fix.line_length;dev_dbg (info->device,"page->index=%lu y_low=%d y_high=%d\n" , - page->index, y_low, y_high); + pageref->page->index, y_low, y_high);if (y_high > info->var.yres -1 ) y_high = info->var.yres -1 ;if (y_low < dirty_lines_start)
drivers/video/fbdev/broadsheetfb.c +6 -7
@@ -932,7 +932,7 @@ static void broadsheetfb_dpy_update(struct broadsheetfb_par *par)static void broadsheetfb_dpy_deferred_io (struct fb_info *info,struct list_head *pagereflist) {u16 y1 =0 , h =0 ; -int prev_index =-1 ; +unsigned long prev_offset =ULONG_MAX ;struct fb_deferred_io_pageref *pageref;int h_inc;u16 yres = info->var.yres;
@@ -943,22 +943,21 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info, struct list_head/* walk the written page list and swizzle the data */ list_for_each_entry (pageref, pagereflist, list) { -struct page *cur = pageref->page; -if (prev_index <0 ) { +if (prev_offset ==ULONG_MAX ) {/* just starting so assign first page */ - y1 = (cur->index <<PAGE_SHIFT ) / xres; + y1 = pageref->offset / xres; h = h_inc; - }else if ((prev_index +1 ) == cur->index) { + }else if ((prev_offset +PAGE_SIZE ) == pageref->offset) {/* this page is consecutive so increase our height */ h += h_inc; }else {/* page not consecutive, issue previous update first */ broadsheetfb_dpy_update_pages (info->par, y1, y1 + h);/* start over with our non consecutive page */ - y1 = (cur->index <<PAGE_SHIFT ) / xres; + y1 = pageref->offset / xres; h = h_inc; } - prev_index = cur->index; + prev_offset = pageref->offset; }/* if we still have any pages to update we do so now */
drivers/video/fbdev/hyperv_fb.c +1 -2
@@ -437,8 +437,7 @@ static void synthvid_deferred_io(struct fb_info *p, struct list_head *pagereflis* value to yres. */ list_for_each_entry (pageref, pagereflist, list) { -struct page *page = pageref->page; - start = page->index <<PAGE_SHIFT ; + start = pageref->offset; end = start +PAGE_SIZE -1 ; y1 = start / p->fix.line_length; y2 = end / p->fix.line_length;
drivers/video/fbdev/metronomefb.c +4 -5
@@ -473,11 +473,10 @@ static void metronomefb_dpy_deferred_io(struct fb_info *info, struct list_head */* walk the written page list and swizzle the data */ list_for_each_entry (pageref, pagereflist, list) { -struct page *cur = pageref->page; - cksum =metronomefb_dpy_update_page (par, - (cur->index <<PAGE_SHIFT )); - par->metromem_img_csum -= par->csum_table[cur->index]; - par->csum_table[cur->index] = cksum; +unsigned long pgoffset = pageref->offset >>PAGE_SHIFT ; + cksum =metronomefb_dpy_update_page (par, pageref->offset); + par->metromem_img_csum -= par->csum_table[pgoffset]; + par->csum_table[pgoffset] = cksum; par->metromem_img_csum += cksum; }
drivers/video/fbdev/sh_mobile_lcdcfb.c +1 -2
@@ -445,8 +445,7 @@ static int sh_mobile_lcdc_sginit(struct fb_info *info, struct list_head *pagerefsg_init_table (ch->sglist, nr_pages_max);list_for_each_entry (pageref, pagereflist, list) { -struct page *page = pageref->page; -sg_set_page (&ch->sglist[nr_pages++], page,PAGE_SIZE ,0 ); +sg_set_page (&ch->sglist[nr_pages++], pageref->page,PAGE_SIZE ,0 ); }return nr_pages;
drivers/video/fbdev/smscufx.c +1 -2
@@ -970,10 +970,9 @@ static void ufx_dpy_deferred_io(struct fb_info *info, struct list_head *pagerefllist_for_each_entry (pageref, pagereflist, list) {/* create a rectangle of full screen width that encloses the * entire dirty framebuffer page */ -struct page *cur = pageref->page;const int x =0 ;const int width = dev->info->var.xres; -const int y = (cur->index <<PAGE_SHIFT ) / (width *2 ); +const int y = pageref->offset / (width *2 );int height = (PAGE_SIZE / (width *2 )) +1 ; height =min (height, (int )(dev->info->var.yres - y));
drivers/video/fbdev/udlfb.c +2 -4
@@ -810,11 +810,9 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, struct list_head *pageref/* walk the written page list and render each to device */ list_for_each_entry (pageref, pagereflist, list) { -struct page *cur = pageref->page; -if (dlfb_render_hline (dlfb, &urb, (char *) info->fix.smem_start, - &cmd, cur->index <<PAGE_SHIFT , -PAGE_SIZE , &bytes_identical, &bytes_sent)) + &cmd, pageref->offset,PAGE_SIZE , + &bytes_identical, &bytes_sent)) goto error; bytes_rendered +=PAGE_SIZE ; }
drivers/video/fbdev/xen-fbfront.c +1 -2
@@ -191,8 +191,7 @@ static void xenfb_deferred_io(struct fb_info *fb_info, struct list_head *pageref miny =INT_MAX ; maxy =0 ;list_for_each_entry (pageref, pagereflist, list) { -struct page *page = pageref->page; - beg = page->index <<PAGE_SHIFT ; + beg = pageref->offset; end = beg +PAGE_SIZE -1 ; y1 = beg / fb_info->fix.line_length; y2 = end / fb_info->fix.line_length;
Signature · 1 line
2.36.0