aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-04-21 16:16:26 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-06-03 05:41:49 -0400
commit888ca5d26ad5975fbe69f0bc1cca5756b529c785 (patch)
tree340c48713d903ecbeff3fd6d39c2acd7078323fb
parent78084dcf2926a646de42041454c13836a6fc44c6 (diff)
video: fbdev: matrox: use arch_phys_wc_add() and ioremap_wc()
This driver uses the same ioremap()'d area for the MTRR. 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: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Julia Lawall <Julia.Lawall@lip6.fr> Cc: Mikulas Patocka <mpatocka@redhat.com> 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: Andy Lutomirski <luto@amacapital.net> Cc: Dave Airlie <airlied@redhat.com> Cc: Antonino Daplas <adaplas@gmail.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/matrox/matroxfb_base.c36
-rw-r--r--drivers/video/fbdev/matrox/matroxfb_base.h27
2 files changed, 14 insertions, 49 deletions
diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c
index 2ba4e54bb59d..11eb094396ae 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.c
+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
@@ -370,12 +370,9 @@ static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
370 matroxfb_unregister_device(minfo); 370 matroxfb_unregister_device(minfo);
371 unregister_framebuffer(&minfo->fbcon); 371 unregister_framebuffer(&minfo->fbcon);
372 matroxfb_g450_shutdown(minfo); 372 matroxfb_g450_shutdown(minfo);
373#ifdef CONFIG_MTRR 373 arch_phys_wc_del(minfo->wc_cookie);
374 if (minfo->mtrr.vram_valid) 374 iounmap(minfo->mmio.vbase.vaddr);
375 mtrr_del(minfo->mtrr.vram, minfo->video.base, minfo->video.len); 375 iounmap(minfo->video.vbase.vaddr);
376#endif
377 mga_iounmap(minfo->mmio.vbase);
378 mga_iounmap(minfo->video.vbase);
379 release_mem_region(minfo->video.base, minfo->video.len_maximum); 376 release_mem_region(minfo->video.base, minfo->video.len_maximum);
380 release_mem_region(minfo->mmio.base, 16384); 377 release_mem_region(minfo->mmio.base, 16384);
381 kfree(minfo); 378 kfree(minfo);
@@ -1252,9 +1249,7 @@ static int nobios; /* "matroxfb:nobios" */
1252static int noinit = 1; /* "matroxfb:init" */ 1249static int noinit = 1; /* "matroxfb:init" */
1253static int inverse; /* "matroxfb:inverse" */ 1250static int inverse; /* "matroxfb:inverse" */
1254static int sgram; /* "matroxfb:sgram" */ 1251static int sgram; /* "matroxfb:sgram" */
1255#ifdef CONFIG_MTRR
1256static int mtrr = 1; /* "matroxfb:nomtrr" */ 1252static int mtrr = 1; /* "matroxfb:nomtrr" */
1257#endif
1258static int grayscale; /* "matroxfb:grayscale" */ 1253static int grayscale; /* "matroxfb:grayscale" */
1259static int dev = -1; /* "matroxfb:dev:xxxxx" */ 1254static int dev = -1; /* "matroxfb:dev:xxxxx" */
1260static unsigned int vesa = ~0; /* "matroxfb:vesa:xxxxx" */ 1255static unsigned int vesa = ~0; /* "matroxfb:vesa:xxxxx" */
@@ -1713,14 +1708,17 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
1713 if (mem && (mem < memsize)) 1708 if (mem && (mem < memsize))
1714 memsize = mem; 1709 memsize = mem;
1715 err = -ENOMEM; 1710 err = -ENOMEM;
1716 if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, &minfo->mmio.vbase)) { 1711
1712 minfo->mmio.vbase.vaddr = ioremap_nocache(ctrlptr_phys, 16384);
1713 if (!minfo->mmio.vbase.vaddr) {
1717 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys); 1714 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys);
1718 goto failVideoMR; 1715 goto failVideoMR;
1719 } 1716 }
1720 minfo->mmio.base = ctrlptr_phys; 1717 minfo->mmio.base = ctrlptr_phys;
1721 minfo->mmio.len = 16384; 1718 minfo->mmio.len = 16384;
1722 minfo->video.base = video_base_phys; 1719 minfo->video.base = video_base_phys;
1723 if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, &minfo->video.vbase)) { 1720 minfo->video.vbase.vaddr = ioremap_wc(video_base_phys, memsize);
1721 if (!minfo->video.vbase.vaddr) {
1724 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n", 1722 printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n",
1725 video_base_phys, memsize); 1723 video_base_phys, memsize);
1726 goto failCtrlIO; 1724 goto failCtrlIO;
@@ -1768,13 +1766,9 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
1768 minfo->video.len_usable = minfo->video.len; 1766 minfo->video.len_usable = minfo->video.len;
1769 if (minfo->video.len_usable > b->base->maxdisplayable) 1767 if (minfo->video.len_usable > b->base->maxdisplayable)
1770 minfo->video.len_usable = b->base->maxdisplayable; 1768 minfo->video.len_usable = b->base->maxdisplayable;
1771#ifdef CONFIG_MTRR 1769 if (mtrr)
1772 if (mtrr) { 1770 minfo->wc_cookie = arch_phys_wc_add(video_base_phys,
1773 minfo->mtrr.vram = mtrr_add(video_base_phys, minfo->video.len, MTRR_TYPE_WRCOMB, 1); 1771 minfo->video.len);
1774 minfo->mtrr.vram_valid = 1;
1775 printk(KERN_INFO "matroxfb: MTRR's turned on\n");
1776 }
1777#endif /* CONFIG_MTRR */
1778 1772
1779 if (!minfo->devflags.novga) 1773 if (!minfo->devflags.novga)
1780 request_region(0x3C0, 32, "matrox"); 1774 request_region(0x3C0, 32, "matrox");
@@ -1943,9 +1937,9 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
1943 return 0; 1937 return 0;
1944failVideoIO:; 1938failVideoIO:;
1945 matroxfb_g450_shutdown(minfo); 1939 matroxfb_g450_shutdown(minfo);
1946 mga_iounmap(minfo->video.vbase); 1940 iounmap(minfo->video.vbase.vaddr);
1947failCtrlIO:; 1941failCtrlIO:;
1948 mga_iounmap(minfo->mmio.vbase); 1942 iounmap(minfo->mmio.vbase.vaddr);
1949failVideoMR:; 1943failVideoMR:;
1950 release_mem_region(video_base_phys, minfo->video.len_maximum); 1944 release_mem_region(video_base_phys, minfo->video.len_maximum);
1951failCtrlMR:; 1945failCtrlMR:;
@@ -2439,10 +2433,8 @@ static int __init matroxfb_setup(char *options) {
2439 nobios = !value; 2433 nobios = !value;
2440 else if (!strcmp(this_opt, "init")) 2434 else if (!strcmp(this_opt, "init"))
2441 noinit = !value; 2435 noinit = !value;
2442#ifdef CONFIG_MTRR
2443 else if (!strcmp(this_opt, "mtrr")) 2436 else if (!strcmp(this_opt, "mtrr"))
2444 mtrr = value; 2437 mtrr = value;
2445#endif
2446 else if (!strcmp(this_opt, "inv24")) 2438 else if (!strcmp(this_opt, "inv24"))
2447 inv24 = value; 2439 inv24 = value;
2448 else if (!strcmp(this_opt, "cross4MB")) 2440 else if (!strcmp(this_opt, "cross4MB"))
@@ -2511,10 +2503,8 @@ module_param(noinit, int, 0);
2511MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not initialize) (default=0)"); 2503MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not initialize) (default=0)");
2512module_param(memtype, int, 0); 2504module_param(memtype, int, 0);
2513MODULE_PARM_DESC(memtype, "Memory type for G200/G400 (see Documentation/fb/matroxfb.txt for explanation) (default=3 for G200, 0 for G400)"); 2505MODULE_PARM_DESC(memtype, "Memory type for G200/G400 (see Documentation/fb/matroxfb.txt for explanation) (default=3 for G200, 0 for G400)");
2514#ifdef CONFIG_MTRR
2515module_param(mtrr, int, 0); 2506module_param(mtrr, int, 0);
2516MODULE_PARM_DESC(mtrr, "This speeds up video memory accesses (0=disabled or 1) (default=1)"); 2507MODULE_PARM_DESC(mtrr, "This speeds up video memory accesses (0=disabled or 1) (default=1)");
2517#endif
2518module_param(sgram, int, 0); 2508module_param(sgram, int, 0);
2519MODULE_PARM_DESC(sgram, "Indicates that G100/G200/G400 has SGRAM memory (0=SDRAM, 1=SGRAM) (default=0)"); 2509MODULE_PARM_DESC(sgram, "Indicates that G100/G200/G400 has SGRAM memory (0=SDRAM, 1=SGRAM) (default=0)");
2520module_param(inv24, int, 0); 2510module_param(inv24, int, 0);
diff --git a/drivers/video/fbdev/matrox/matroxfb_base.h b/drivers/video/fbdev/matrox/matroxfb_base.h
index 89a8a89a5eb2..09b02cd1eb0e 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.h
+++ b/drivers/video/fbdev/matrox/matroxfb_base.h
@@ -44,9 +44,6 @@
44 44
45#include <asm/io.h> 45#include <asm/io.h>
46#include <asm/unaligned.h> 46#include <asm/unaligned.h>
47#ifdef CONFIG_MTRR
48#include <asm/mtrr.h>
49#endif
50 47
51#if defined(CONFIG_PPC_PMAC) 48#if defined(CONFIG_PPC_PMAC)
52#include <asm/prom.h> 49#include <asm/prom.h>
@@ -187,23 +184,6 @@ static inline void __iomem* vaddr_va(vaddr_t va) {
187 return va.vaddr; 184 return va.vaddr;
188} 185}
189 186
190#define MGA_IOREMAP_NORMAL 0
191#define MGA_IOREMAP_NOCACHE 1
192
193#define MGA_IOREMAP_FB MGA_IOREMAP_NOCACHE
194#define MGA_IOREMAP_MMIO MGA_IOREMAP_NOCACHE
195static inline int mga_ioremap(unsigned long phys, unsigned long size, int flags, vaddr_t* virt) {
196 if (flags & MGA_IOREMAP_NOCACHE)
197 virt->vaddr = ioremap_nocache(phys, size);
198 else
199 virt->vaddr = ioremap(phys, size);
200 return (virt->vaddr == NULL); /* 0, !0... 0, error_code in future */
201}
202
203static inline void mga_iounmap(vaddr_t va) {
204 iounmap(va.vaddr);
205}
206
207struct my_timming { 187struct my_timming {
208 unsigned int pixclock; 188 unsigned int pixclock;
209 int mnp; 189 int mnp;
@@ -449,12 +429,7 @@ struct matrox_fb_info {
449 int plnwt; 429 int plnwt;
450 int srcorg; 430 int srcorg;
451 } capable; 431 } capable;
452#ifdef CONFIG_MTRR 432 int wc_cookie;
453 struct {
454 int vram;
455 int vram_valid;
456 } mtrr;
457#endif
458 struct { 433 struct {
459 int precise_width; 434 int precise_width;
460 int mga_24bpp_fix; 435 int mga_24bpp_fix;