framebuffer: simple conversions to arch_phys_wc_add()
v4 cover framebuffer: simple conversions to arch_phys_wc_add()
From: "Luis R. Rodriguez" <[email protected]>
Tomi,
Upon integration onto your tree of the series, "[PATCH v3 00/17] framebuffer:
simple conversions to arch_phys_wc_add()" the 0 day build bot found a compilation issue on the gbefb driver. I had test compiled drivers with allyesconfig and allmodconfig but failed to test compile against MIPS. This driver is enabled *only for MIPS*. For the life me I could not get a MIPS cross compiler even on debian, so what I did to test this was incorporate into my private tree a temporary patch [0] which enables this driver to compile on x86 and go test compile with that as a temporary patch. The compilation was failing since I used the info struct instead of the actual private data structure. This fixes that and moves its assignment early. Sorry about that.
The rest of the series does not require changes for integration after these two patch replacements. Let me know if you'd like me to respin the entire series though, but I didn't since I figured its pointless as the patches remain intact. For your convenience however I've rebased all these 17 patches onto your latest tree on the for-next branch, you can pull the changes with the details provided below. This v4 iteration only carries the two patches which required updates. The details of the full pull request go below this.
[0] http://drvbp1.linux-foundation.org/~mcgrof/patches/tmp/enable-gbefb-x86.patch
Luis R. Rodriguez (2):
video: fbdev: gbefb: add missing mtrr_del() calls
video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
drivers/video/fbdev/gbefb.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
The following changes since commit 36520841a443d5ee966f9632c417fcc8a25e07e3:
video/console: use swap() in newport_bmove() (2015-05-27 12:54:49 +0300)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-framebuffer.git simple-arch_phys-20150528
for you to fetch changes up to 29b0c802f84943cac3658927452a2da4c976c632:
video: fbdev: geode gxfb: use ioremap_wc() for framebuffer (2015-05-28 17:16:43 -0700)
----------------------------------------------------------------
Luis R. Rodriguez (17):
video: fbdev: radeonfb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: gbefb: add missing mtrr_del() calls
video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
video: fbdev: intelfb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: matrox: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: neofb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: nvidia: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: savagefb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: sisfb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: aty: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: i810: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: pm2fb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: pm3fb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: rivafb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: tdfxfb: use arch_phys_wc_add() and ioremap_wc()
video: fbdev: atmel_lcdfb: use ioremap_wc() for framebuffer
video: fbdev: geode gxfb: use ioremap_wc() for framebuffer
drivers/video/fbdev/atmel_lcdfb.c | 3 +- drivers/video/fbdev/aty/aty128fb.c | 36 ++++-------------------- drivers/video/fbdev/aty/radeon_base.c | 29 ++++---------------- drivers/video/fbdev/aty/radeonfb.h | 2 +- drivers/video/fbdev/gbefb.c | 21 +++++++------- drivers/video/fbdev/geode/gxfb_core.c | 3 +- drivers/video/fbdev/i810/i810.h | 3 +- drivers/video/fbdev/i810/i810_main.c | 11 +++++--- drivers/video/fbdev/i810/i810_main.h | 26 ------------------ drivers/video/fbdev/intelfb/intelfb.h | 4 +-- drivers/video/fbdev/intelfb/intelfbdrv.c | 38 +++----------------------- drivers/video/fbdev/matrox/matroxfb_base.c | 36 +++++++++--------------- drivers/video/fbdev/matrox/matroxfb_base.h | 27 +----------------- drivers/video/fbdev/neofb.c | 26 +++++------------- drivers/video/fbdev/nvidia/nv_type.h | 7 +---- drivers/video/fbdev/nvidia/nvidia.c | 37 ++++--------------------- drivers/video/fbdev/pm2fb.c | 31 ++++----------------- drivers/video/fbdev/pm3fb.c | 30 ++++---------------- drivers/video/fbdev/riva/fbdev.c | 39 +++++--------------------- drivers/video/fbdev/riva/rivafb.h | 4 +-- drivers/video/fbdev/savage/savagefb.h | 4 +-- drivers/video/fbdev/savage/savagefb_driver.c | 17 ++---------- drivers/video/fbdev/sis/sis.h | 2 +- drivers/video/fbdev/sis/sis_main.c | 27 ++++-------------- drivers/video/fbdev/tdfxfb.c | 41 ++++------------------------ include/video/neomagic.h | 5 +--- include/video/tdfx.h | 2 +- 27 files changed, 106 insertions(+), 405 deletions(-)
PATCH v4 2/17 video: fbdev: gbefb: add missing mtrr_del() calls
From: "Luis R. Rodriguez" <[email protected]>
This driver never removed the MTRRs. Fix that.
--- drivers/video/fbdev/gbefb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/video/fbdev/gbefb.c +13 -2
@@ -38,6 +38,7 @@ static struct sgi_gbe *gbe;struct gbefb_par {struct fb_var_screeninfo var;struct gbe_timing_info timing; +int wc_cookie;int valid; };
@@ -1198,8 +1199,10 @@ static int gbefb_probe(struct platform_device *p_dev) gbe_mem_phys = (unsigned long ) gbe_dma_addr; } + par = info->par;#ifdef CONFIG_X86 -mtrr_add (gbe_mem_phys, gbe_mem_size,MTRR_TYPE_WRCOMB ,1 ); + par->wc_cookie =mtrr_add (gbe_mem_phys, gbe_mem_size, +MTRR_TYPE_WRCOMB ,1 );#endif /* map framebuffer memory into tiles table */
@@ -1215,7 +1218,6 @@ static int gbefb_probe(struct platform_device *p_dev)/* reset GBE */ gbe_reset (); - par = info->par;/* turn on default video mode */ if (fb_find_mode (&par->var, info, mode_option,NULL ,0 , default_mode,8 ) =0 )
@@ -1240,6 +1242,10 @@ static int gbefb_probe(struct platform_device *p_dev)return 0 ; out_gbe_unmap: +#ifdef CONFIG_MTRR +if (par->wc_cookie >=0 ) +mtrr_del (par->wc_cookie,0 ,0 ); +#endif if (gbe_dma_addr)dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); out_tiles_free:
@@ -1256,9 +1262,14 @@ out_release_framebuffer:static int gbefb_remove (struct platform_device * p_dev) {struct fb_info *info =platform_get_drvdata (p_dev); +struct gbefb_par *par = info->par;unregister_framebuffer (info);gbe_turn_off (); +#ifdef CONFIG_MTRR +if (par->wc_cookie >=0 ) +mtrr_del (par->wc_cookie,0 ,0 ); +#endif if (gbe_dma_addr)dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t),
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v4 3/17 video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Convert the driver from using the x86 specific MTRR code to the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add() will avoid MTRR if write-combining is available, in order to take advantage of that also ensure the ioremap'd area is requested as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle SmPL patch, it additionally required manual intervention to address all the #ifdery and removal of redundant things which arch_phys_wc_add() already addresses such as verbose message about when MTRR fails and doing nothing when we didn't get an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1); +index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size; @@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len); +arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
--- drivers/video/fbdev/gbefb.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/video/fbdev/gbefb.c +7 -19
@@ -22,9 +22,6 @@#include <linux/module.h> #include <linux/io.h> -#ifdef CONFIG_X86 -#include <asm/mtrr.h> -#endif #ifdef CONFIG_MIPS #include <asm/addrspace.h> #endif
@@ -1176,8 +1173,8 @@ static int gbefb_probe(struct platform_device *p_dev)if (gbe_mem_phys) {/* memory was allocated at boot time */ - gbe_mem =devm_ioremap_nocache (&p_dev->dev, gbe_mem_phys, - gbe_mem_size); + gbe_mem =devm_ioremap_wc (&p_dev->dev, gbe_mem_phys, + gbe_mem_size);if (!gbe_mem) {printk (KERN_ERR "gbefb: couldn't map framebuffer\n" ); ret = -ENOMEM ;
@@ -1188,8 +1185,8 @@ static int gbefb_probe(struct platform_device *p_dev) }else {/* try to allocate memory with the classical allocator * this has high chance to fail on low memory machines */ - gbe_mem =dma_alloc_coherent (NULL , gbe_mem_size, &gbe_dma_addr, -GFP_KERNEL ); + gbe_mem =dma_alloc_writecombine (NULL , gbe_mem_size, + &gbe_dma_addr,GFP_KERNEL );if (!gbe_mem) {printk (KERN_ERR "gbefb: couldn't allocate framebuffer memory\n" ); ret = -ENOMEM ;
@@ -1200,10 +1197,7 @@ static int gbefb_probe(struct platform_device *p_dev) } par = info->par; -#ifdef CONFIG_X86 - par->wc_cookie =mtrr_add (gbe_mem_phys, gbe_mem_size, -MTRR_TYPE_WRCOMB ,1 ); -#endif + par->wc_cookie =arch_phys_wc_add (gbe_mem_phys, gbe_mem_size);/* map framebuffer memory into tiles table */ for (i =0 ; i < (gbe_mem_size >>TILE_SHIFT ); i++)
@@ -1242,10 +1236,7 @@ static int gbefb_probe(struct platform_device *p_dev)return 0 ; out_gbe_unmap: -#ifdef CONFIG_MTRR -if (par->wc_cookie >=0 ) -mtrr_del (par->wc_cookie,0 ,0 ); -#endif +arch_phys_wc_del (par->wc_cookie);if (gbe_dma_addr)dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); out_tiles_free:
@@ -1266,10 +1257,7 @@ static int gbefb_remove(struct platform_device* p_dev)unregister_framebuffer (info);gbe_turn_off (); -#ifdef CONFIG_MTRR -if (par->wc_cookie >=0 ) -mtrr_del (par->wc_cookie,0 ,0 ); -#endif +arch_phys_wc_del (par->wc_cookie);if (gbe_dma_addr)dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t),
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
Re: [PATCH v4 3/17] video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
Review
Quoted 11 lines · Luis R. Rodriguez
(quoted diff) +7
-0+ gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys, + gbe_mem_size); + gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL); + par->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size); + arch_phys_wc_del(par->wc_cookie); + arch_phys_wc_del(par->wc_cookie);
Could we _please_ rename dma_*_writecombine() to dma_*_wc(), so that the naming is coherent across the various APIs?
Thanks,
Ingo
Re: [PATCH v4 3/17] video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
Quoted 9 lines · Ingo Molnar
Quoted 5 lines · Luis R. Rodriguez
(quoted diff) +4
-0+ gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys, + gbe_mem_size); + gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL);
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +3
-0+ par->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size); + arch_phys_wc_del(par->wc_cookie); + arch_phys_wc_del(par->wc_cookie);Could we _please_ rename dma_*_writecombine() to dma_*_wc(), so that the naming is coherent across the various APIs?
Sure, OK done. Will send once this series is merged and visible on linux-next. But who's tree should this go through? Since it depends on this series which goes through Tomi's tree should it go through there?
Luis
Re: [PATCH v4 3/17] video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
Quoted 14 lines · Luis R. Rodriguez
Quoted 13 lines · Ingo Molnar
Quoted 9 lines · Luis R. Rodriguez
(quoted diff) +6
-0+ gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys, + gbe_mem_size); + gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL); + par->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size); + arch_phys_wc_del(par->wc_cookie);
Quoted 8 lines
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ arch_phys_wc_del(par->wc_cookie);Could we _please_ rename dma_*_writecombine() to dma_*_wc(), so that the naming is coherent across the various APIs?
Sure, OK done. Will send once this series is merged and visible on linux-next. But who's tree should this go through? Since it depends on this series which goes through Tomi's tree should it go through there?
So we could do the rename near the end of the merge window, when all the patches have drained from maintainer trees into Linus's tree. Mind keeping it in your tree until then?
Thanks,
Ingo
Re: [PATCH v4 3/17] video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()
Quoted 22 lines · Ingo Molnar
Quoted 19 lines · Luis R. Rodriguez
Quoted 17 lines · Ingo Molnar
Review
Quoted 11 lines · Luis R. Rodriguez
(quoted diff) +7
-0+ gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys, + gbe_mem_size); + gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL); + par->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size); + arch_phys_wc_del(par->wc_cookie); + arch_phys_wc_del(par->wc_cookie);Could we _please_ rename dma_*_writecombine() to dma_*_wc(), so that the naming is coherent across the various APIs?
Quoted 6 lines
Quoted 3 lines
Sure, OK done. Will send once this series is merged and visible on linux-next. But who's tree should this go through? Since it depends on this series which goes through Tomi's tree should it go through there?
So we could do the rename near the end of the merge window, when all the patches have drained from maintainer trees into Linus's tree.
OK.
Quoted 1 line
Mind keeping it in your tree until then?
You got it.
Luis
Quoted 15 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Tomi,
Upon integration onto your tree of the series, "[PATCH v3 00/17] framebuffer:
simple conversions toarch_phys_wc_add()" the 0 day build bot found a compilation issue on the gbefb driver. I had test compiled drivers with allyesconfig and allmodconfig but failed to test compile against MIPS. This driver is enabled *only for MIPS*. For the life me I could not get a MIPS cross compiler even on debian, so what I did to test this was incorporate into my private tree a temporary patch [0] which enables this driver to compile on x86 and go test compile with that as a temporary patch. The compilation was failing since I used the info struct instead of the actual private data structure. This fixes that and moves its assignment early. Sorry about that.
Quoted 7 lines
The rest of the series does not require changes for integration after these two patch replacements. Let me know if you'd like me to respin the entire series though, but I didn't since I figured its pointless as the patches remain intact. For your convenience however I've rebased all these 17 patches onto your latest tree on the for-next branch, you can pull the changes with the details provided below. This v4 iteration only carries the two patches which required updates. The details of the full pull request go below this.
Thanks, I've updated the two patches, and pushed the series to my for-next.
Tomi
Quoted 26 lines · Tomi Valkeinen
Quoted 15 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Tomi,
Upon integration onto your tree of the series, "[PATCH v3 00/17] framebuffer:
simple conversions toarch_phys_wc_add()" the 0 day build bot found a compilation issue on the gbefb driver. I had test compiled drivers with allyesconfig and allmodconfig but failed to test compile against MIPS. This driver is enabled *only for MIPS*. For the life me I could not get a MIPS cross compiler even on debian, so what I did to test this was incorporate into my private tree a temporary patch [0] which enables this driver to compile on x86 and go test compile with that as a temporary patch. The compilation was failing since I used the info struct instead of the actual private data structure. This fixes that and moves its assignment early. Sorry about that.Quoted 7 lines
The rest of the series does not require changes for integration after these two patch replacements. Let me know if you'd like me to respin the entire series though, but I didn't since I figured its pointless as the patches remain intact. For your convenience however I've rebased all these 17 patches onto your latest tree on the for-next branch, you can pull the changes with the details provided below. This v4 iteration only carries the two patches which required updates. The details of the full pull request go below this.
Quoted 1 line
Thanks, I've updated the two patches, and pushed the series to my for-next.
And yet another corner case, which compilation would not have picked up but only grammar would. Best handled now before it being merged. The same gbefb MIPS patch had a missing change from dma_free_coherent() to dma_free_writecombine(), this is needed since the gbefb is changed to use dma_alloc_writecombine(). The change required is illustrated below. Terribly sorry about that... I'll send a v5 pull request unless you want that to go separately. Meanwhile I've verified the other series I have for MTRR and none of them use these APIs so this is the only one with this inconsistancy.
drivers/video/fbdev/gbefb.c +2 -2
@@ -1238,7 +1238,7 @@ static int gbefb_probe(struct platform_device *p_dev) out_gbe_unmap:arch_phys_wc_del (par->wc_cookie);if (gbe_dma_addr) -dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); +dma_free_writecombine (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); out_tiles_free:dma_free_coherent (NULL ,GBE_TLB_SIZE *sizeof (uint16_t ), (void *)gbe_tiles.cpu, gbe_tiles.dma);
@@ -1259,7 +1259,7 @@ static int gbefb_remove(struct platform_device* p_dev)gbe_turn_off ();arch_phys_wc_del (par->wc_cookie);if (gbe_dma_addr) -dma_free_coherent (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys); +dma_free_writecombine (NULL , gbe_mem_size, gbe_mem, gbe_mem_phys);dma_free_coherent (NULL ,GBE_TLB_SIZE *sizeof (uint16_t ), (void *)gbe_tiles.cpu, gbe_tiles.dma);release_mem_region (GBE_BASE ,sizeof (struct sgi_gbe ));
Luis