aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-04-21 16:16:31 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-06-03 05:41:51 -0400
commitf4447dde3c74a02b3e109049f560b03897ca1488 (patch)
tree98f5e56b4f267aa19847d0b86014e517dc608254
parent2cff64062e513dd32bde585e8dc87796742e8b59 (diff)
video: fbdev: aty: use arch_phys_wc_add() and ioremap_wc()
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); Generated-by: Coccinelle SmPL Cc: Paul Mackerras <paulus@samba.org> Cc: Suresh Siddha <sbsiddha@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Juergen Gross <jgross@suse.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Dave Airlie <airlied@redhat.com> Cc: Antonino Daplas <adaplas@gmail.com> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/fbdev/aty/aty128fb.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
index 0156954bf340..c42ce2fdfd44 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -80,10 +80,6 @@
80#include <asm/btext.h> 80#include <asm/btext.h>
81#endif /* CONFIG_BOOTX_TEXT */ 81#endif /* CONFIG_BOOTX_TEXT */
82 82
83#ifdef CONFIG_MTRR
84#include <asm/mtrr.h>
85#endif
86
87#include <video/aty128.h> 83#include <video/aty128.h>
88 84
89/* Debug flag */ 85/* Debug flag */
@@ -399,10 +395,7 @@ static int default_cmode = CMODE_8;
399 395
400static int default_crt_on = 0; 396static int default_crt_on = 0;
401static int default_lcd_on = 1; 397static int default_lcd_on = 1;
402
403#ifdef CONFIG_MTRR
404static bool mtrr = true; 398static bool mtrr = true;
405#endif
406 399
407#ifdef CONFIG_FB_ATY128_BACKLIGHT 400#ifdef CONFIG_FB_ATY128_BACKLIGHT
408#ifdef CONFIG_PMAC_BACKLIGHT 401#ifdef CONFIG_PMAC_BACKLIGHT
@@ -456,9 +449,7 @@ struct aty128fb_par {
456 u32 vram_size; /* onboard video ram */ 449 u32 vram_size; /* onboard video ram */
457 int chip_gen; 450 int chip_gen;
458 const struct aty128_meminfo *mem; /* onboard mem info */ 451 const struct aty128_meminfo *mem; /* onboard mem info */
459#ifdef CONFIG_MTRR 452 int wc_cookie;
460 struct { int vram; int vram_valid; } mtrr;
461#endif
462 int blitter_may_be_busy; 453 int blitter_may_be_busy;
463 int fifo_slots; /* free slots in FIFO (64 max) */ 454 int fifo_slots; /* free slots in FIFO (64 max) */
464 455
@@ -1725,12 +1716,10 @@ static int aty128fb_setup(char *options)
1725#endif 1716#endif
1726 continue; 1717 continue;
1727 } 1718 }
1728#ifdef CONFIG_MTRR
1729 if(!strncmp(this_opt, "nomtrr", 6)) { 1719 if(!strncmp(this_opt, "nomtrr", 6)) {
1730 mtrr = 0; 1720 mtrr = 0;
1731 continue; 1721 continue;
1732 } 1722 }
1733#endif
1734#ifdef CONFIG_PPC_PMAC 1723#ifdef CONFIG_PPC_PMAC
1735 /* vmode and cmode deprecated */ 1724 /* vmode and cmode deprecated */
1736 if (!strncmp(this_opt, "vmode:", 6)) { 1725 if (!strncmp(this_opt, "vmode:", 6)) {
@@ -2133,7 +2122,7 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2133 par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF; 2122 par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF;
2134 2123
2135 /* Virtualize the framebuffer */ 2124 /* Virtualize the framebuffer */
2136 info->screen_base = ioremap(fb_addr, par->vram_size); 2125 info->screen_base = ioremap_wc(fb_addr, par->vram_size);
2137 if (!info->screen_base) 2126 if (!info->screen_base)
2138 goto err_unmap_out; 2127 goto err_unmap_out;
2139 2128
@@ -2170,15 +2159,9 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2170 if (!aty128_init(pdev, ent)) 2159 if (!aty128_init(pdev, ent))
2171 goto err_out; 2160 goto err_out;
2172 2161
2173#ifdef CONFIG_MTRR 2162 if (mtrr)
2174 if (mtrr) { 2163 par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
2175 par->mtrr.vram = mtrr_add(info->fix.smem_start, 2164 par->vram_size);
2176 par->vram_size, MTRR_TYPE_WRCOMB, 1);
2177 par->mtrr.vram_valid = 1;
2178 /* let there be speed */
2179 printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n");
2180 }
2181#endif /* CONFIG_MTRR */
2182 return 0; 2165 return 0;
2183 2166
2184err_out: 2167err_out:
@@ -2212,11 +2195,7 @@ static void aty128_remove(struct pci_dev *pdev)
2212 aty128_bl_exit(info->bl_dev); 2195 aty128_bl_exit(info->bl_dev);
2213#endif 2196#endif
2214 2197
2215#ifdef CONFIG_MTRR 2198 arch_phys_wc_del(par->wc_cookie);
2216 if (par->mtrr.vram_valid)
2217 mtrr_del(par->mtrr.vram, info->fix.smem_start,
2218 par->vram_size);
2219#endif /* CONFIG_MTRR */
2220 iounmap(par->regbase); 2199 iounmap(par->regbase);
2221 iounmap(info->screen_base); 2200 iounmap(info->screen_base);
2222 2201
@@ -2625,8 +2604,5 @@ MODULE_DESCRIPTION("FBDev driver for ATI Rage128 / Pro cards");
2625MODULE_LICENSE("GPL"); 2604MODULE_LICENSE("GPL");
2626module_param(mode_option, charp, 0); 2605module_param(mode_option, charp, 0);
2627MODULE_PARM_DESC(mode_option, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); 2606MODULE_PARM_DESC(mode_option, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
2628#ifdef CONFIG_MTRR
2629module_param_named(nomtrr, mtrr, invbool, 0); 2607module_param_named(nomtrr, mtrr, invbool, 0);
2630MODULE_PARM_DESC(nomtrr, "bool: Disable MTRR support (0 or 1=disabled) (default=0)"); 2608MODULE_PARM_DESC(nomtrr, "bool: Disable MTRR support (0 or 1=disabled) (default=0)");
2631#endif
2632