aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-04-21 16:16:34 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-06-03 05:41:52 -0400
commit26e2506075f0e0b9ed8909e772404e750a13d3f5 (patch)
tree77132b5172320b322d6a23cfc54fda1694942830
parentf8f05cdc767fa5c7da5ada466b2c5f225e5c818b (diff)
video: fbdev: pm3fb: use arch_phys_wc_add() and ioremap_wc()
This driver uses the same area for MTRR as for the ioremap(). 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: Jingoo Han <jg1.han@samsung.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.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: 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/pm3fb.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c
index 77b99ed39ad0..6ff5077a2e15 100644
--- a/drivers/video/fbdev/pm3fb.c
+++ b/drivers/video/fbdev/pm3fb.c
@@ -32,9 +32,6 @@
32#include <linux/fb.h> 32#include <linux/fb.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#ifdef CONFIG_MTRR
36#include <asm/mtrr.h>
37#endif
38 35
39#include <video/pm3fb.h> 36#include <video/pm3fb.h>
40 37
@@ -58,11 +55,7 @@
58static int hwcursor = 1; 55static int hwcursor = 1;
59static char *mode_option; 56static char *mode_option;
60static bool noaccel; 57static bool noaccel;
61
62/* mtrr option */
63#ifdef CONFIG_MTRR
64static bool nomtrr; 58static bool nomtrr;
65#endif
66 59
67/* 60/*
68 * This structure defines the hardware state of the graphics card. Normally 61 * This structure defines the hardware state of the graphics card. Normally
@@ -76,7 +69,7 @@ struct pm3_par {
76 u32 video; /* video flags before blanking */ 69 u32 video; /* video flags before blanking */
77 u32 base; /* screen base in 128 bits unit */ 70 u32 base; /* screen base in 128 bits unit */
78 u32 palette[16]; 71 u32 palette[16];
79 int mtrr_handle; 72 int wc_cookie;
80}; 73};
81 74
82/* 75/*
@@ -1374,8 +1367,8 @@ static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
1374 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); 1367 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
1375 goto err_exit_mmio; 1368 goto err_exit_mmio;
1376 } 1369 }
1377 info->screen_base = 1370 info->screen_base = ioremap_wc(pm3fb_fix.smem_start,
1378 ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); 1371 pm3fb_fix.smem_len);
1379 if (!info->screen_base) { 1372 if (!info->screen_base) {
1380 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); 1373 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
1381 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); 1374 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
@@ -1383,12 +1376,9 @@ static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
1383 } 1376 }
1384 info->screen_size = pm3fb_fix.smem_len; 1377 info->screen_size = pm3fb_fix.smem_len;
1385 1378
1386#ifdef CONFIG_MTRR
1387 if (!nomtrr) 1379 if (!nomtrr)
1388 par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start, 1380 par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start,
1389 pm3fb_fix.smem_len, 1381 pm3fb_fix.smem_len);
1390 MTRR_TYPE_WRCOMB, 1);
1391#endif
1392 info->fbops = &pm3fb_ops; 1382 info->fbops = &pm3fb_ops;
1393 1383
1394 par->video = PM3_READ_REG(par, PM3VideoControl); 1384 par->video = PM3_READ_REG(par, PM3VideoControl);
@@ -1478,11 +1468,7 @@ static void pm3fb_remove(struct pci_dev *dev)
1478 unregister_framebuffer(info); 1468 unregister_framebuffer(info);
1479 fb_dealloc_cmap(&info->cmap); 1469 fb_dealloc_cmap(&info->cmap);
1480 1470
1481#ifdef CONFIG_MTRR 1471 arch_phys_wc_del(par->wc_cookie);
1482 if (par->mtrr_handle >= 0)
1483 mtrr_del(par->mtrr_handle, info->fix.smem_start,
1484 info->fix.smem_len);
1485#endif /* CONFIG_MTRR */
1486 iounmap(info->screen_base); 1472 iounmap(info->screen_base);
1487 release_mem_region(fix->smem_start, fix->smem_len); 1473 release_mem_region(fix->smem_start, fix->smem_len);
1488 iounmap(par->v_regs); 1474 iounmap(par->v_regs);
@@ -1533,10 +1519,8 @@ static int __init pm3fb_setup(char *options)
1533 noaccel = 1; 1519 noaccel = 1;
1534 else if (!strncmp(this_opt, "hwcursor=", 9)) 1520 else if (!strncmp(this_opt, "hwcursor=", 9))
1535 hwcursor = simple_strtoul(this_opt + 9, NULL, 0); 1521 hwcursor = simple_strtoul(this_opt + 9, NULL, 0);
1536#ifdef CONFIG_MTRR
1537 else if (!strncmp(this_opt, "nomtrr", 6)) 1522 else if (!strncmp(this_opt, "nomtrr", 6))
1538 nomtrr = 1; 1523 nomtrr = 1;
1539#endif
1540 else 1524 else
1541 mode_option = this_opt; 1525 mode_option = this_opt;
1542 } 1526 }
@@ -1577,10 +1561,8 @@ MODULE_PARM_DESC(noaccel, "Disable acceleration");
1577module_param(hwcursor, int, 0644); 1561module_param(hwcursor, int, 0644);
1578MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " 1562MODULE_PARM_DESC(hwcursor, "Enable hardware cursor "
1579 "(1=enable, 0=disable, default=1)"); 1563 "(1=enable, 0=disable, default=1)");
1580#ifdef CONFIG_MTRR
1581module_param(nomtrr, bool, 0); 1564module_param(nomtrr, bool, 0);
1582MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)"); 1565MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)");
1583#endif
1584 1566
1585MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); 1567MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
1586MODULE_LICENSE("GPL"); 1568MODULE_LICENSE("GPL");