summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-04-21 16:16:27 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-06-03 05:41:49 -0400
commitf2081b81c51893c7f2fd8b6d569d1b8de620a2fc (patch)
tree1022ab0fd73a48ddabb1e392bc27b9963cbbfecb
parent888ca5d26ad5975fbe69f0bc1cca5756b529c785 (diff)
video: fbdev: neofb: 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: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Jingoo Han <jg1.han@samsung.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: 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: 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/neofb.c26
-rw-r--r--include/video/neomagic.h5
2 files changed, 8 insertions, 23 deletions
diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c
index 44f99a60bb9b..db023a97d1ea 100644
--- a/drivers/video/fbdev/neofb.c
+++ b/drivers/video/fbdev/neofb.c
@@ -71,11 +71,6 @@
71#include <asm/io.h> 71#include <asm/io.h>
72#include <asm/irq.h> 72#include <asm/irq.h>
73#include <asm/pgtable.h> 73#include <asm/pgtable.h>
74
75#ifdef CONFIG_MTRR
76#include <asm/mtrr.h>
77#endif
78
79#include <video/vga.h> 74#include <video/vga.h>
80#include <video/neomagic.h> 75#include <video/neomagic.h>
81 76
@@ -1710,6 +1705,7 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev,
1710 int video_len) 1705 int video_len)
1711{ 1706{
1712 //unsigned long addr; 1707 //unsigned long addr;
1708 struct neofb_par *par = info->par;
1713 1709
1714 DBG("neo_map_video"); 1710 DBG("neo_map_video");
1715 1711
@@ -1723,7 +1719,7 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev,
1723 } 1719 }
1724 1720
1725 info->screen_base = 1721 info->screen_base =
1726 ioremap(info->fix.smem_start, info->fix.smem_len); 1722 ioremap_wc(info->fix.smem_start, info->fix.smem_len);
1727 if (!info->screen_base) { 1723 if (!info->screen_base) {
1728 printk("neofb: unable to map screen memory\n"); 1724 printk("neofb: unable to map screen memory\n");
1729 release_mem_region(info->fix.smem_start, 1725 release_mem_region(info->fix.smem_start,
@@ -1733,11 +1729,8 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev,
1733 printk(KERN_INFO "neofb: mapped framebuffer at %p\n", 1729 printk(KERN_INFO "neofb: mapped framebuffer at %p\n",
1734 info->screen_base); 1730 info->screen_base);
1735 1731
1736#ifdef CONFIG_MTRR 1732 par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
1737 ((struct neofb_par *)(info->par))->mtrr = 1733 pci_resource_len(dev, 0));
1738 mtrr_add(info->fix.smem_start, pci_resource_len(dev, 0),
1739 MTRR_TYPE_WRCOMB, 1);
1740#endif
1741 1734
1742 /* Clear framebuffer, it's all white in memory after boot */ 1735 /* Clear framebuffer, it's all white in memory after boot */
1743 memset_io(info->screen_base, 0, info->fix.smem_len); 1736 memset_io(info->screen_base, 0, info->fix.smem_len);
@@ -1754,16 +1747,11 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev,
1754 1747
1755static void neo_unmap_video(struct fb_info *info) 1748static void neo_unmap_video(struct fb_info *info)
1756{ 1749{
1757 DBG("neo_unmap_video"); 1750 struct neofb_par *par = info->par;
1758 1751
1759#ifdef CONFIG_MTRR 1752 DBG("neo_unmap_video");
1760 {
1761 struct neofb_par *par = info->par;
1762 1753
1763 mtrr_del(par->mtrr, info->fix.smem_start, 1754 arch_phys_wc_del(par->wc_cookie);
1764 info->fix.smem_len);
1765 }
1766#endif
1767 iounmap(info->screen_base); 1755 iounmap(info->screen_base);
1768 info->screen_base = NULL; 1756 info->screen_base = NULL;
1769 1757
diff --git a/include/video/neomagic.h b/include/video/neomagic.h
index bc5013e8059d..91e225a6107d 100644
--- a/include/video/neomagic.h
+++ b/include/video/neomagic.h
@@ -159,10 +159,7 @@ struct neofb_par {
159 unsigned char VCLK3NumeratorHigh; 159 unsigned char VCLK3NumeratorHigh;
160 unsigned char VCLK3Denominator; 160 unsigned char VCLK3Denominator;
161 unsigned char VerticalExt; 161 unsigned char VerticalExt;
162 162 int wc_cookie;
163#ifdef CONFIG_MTRR
164 int mtrr;
165#endif
166 u8 __iomem *mmio_vbase; 163 u8 __iomem *mmio_vbase;
167 u8 cursorOff; 164 u8 cursorOff;
168 u8 *cursorPad; /* Must die !! */ 165 u8 *cursorPad; /* Must die !! */