aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-04-21 16:16:22 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-05-29 01:45:28 -0400
commit5e200b5352ccc40f39b64df5216772780ef03e7f (patch)
tree1f055782defcf84a9958cdf83579c5fb39585d87
parent36520841a443d5ee966f9632c417fcc8a25e07e3 (diff)
video: fbdev: radeonfb: 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: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.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/aty/radeon_base.c29
-rw-r--r--drivers/video/fbdev/aty/radeonfb.h2
2 files changed, 7 insertions, 24 deletions
diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
index 01237c8fcdc6..2bdb070707e4 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -85,10 +85,6 @@
85 85
86#endif /* CONFIG_PPC */ 86#endif /* CONFIG_PPC */
87 87
88#ifdef CONFIG_MTRR
89#include <asm/mtrr.h>
90#endif
91
92#include <video/radeon.h> 88#include <video/radeon.h>
93#include <linux/radeonfb.h> 89#include <linux/radeonfb.h>
94 90
@@ -271,9 +267,7 @@ static bool mirror = 0;
271static int panel_yres = 0; 267static int panel_yres = 0;
272static bool force_dfp = 0; 268static bool force_dfp = 0;
273static bool force_measure_pll = 0; 269static bool force_measure_pll = 0;
274#ifdef CONFIG_MTRR
275static bool nomtrr = 0; 270static bool nomtrr = 0;
276#endif
277static bool force_sleep; 271static bool force_sleep;
278static bool ignore_devlist; 272static bool ignore_devlist;
279#ifdef CONFIG_PMAC_BACKLIGHT 273#ifdef CONFIG_PMAC_BACKLIGHT
@@ -2260,8 +2254,8 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
2260 rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, rinfo->video_ram); 2254 rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, rinfo->video_ram);
2261 2255
2262 do { 2256 do {
2263 rinfo->fb_base = ioremap (rinfo->fb_base_phys, 2257 rinfo->fb_base = ioremap_wc(rinfo->fb_base_phys,
2264 rinfo->mapped_vram); 2258 rinfo->mapped_vram);
2265 } while (rinfo->fb_base == NULL && 2259 } while (rinfo->fb_base == NULL &&
2266 ((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM)); 2260 ((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM));
2267 2261
@@ -2359,11 +2353,9 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
2359 goto err_unmap_fb; 2353 goto err_unmap_fb;
2360 } 2354 }
2361 2355
2362#ifdef CONFIG_MTRR 2356 if (!nomtrr)
2363 rinfo->mtrr_hdl = nomtrr ? -1 : mtrr_add(rinfo->fb_base_phys, 2357 rinfo->wc_cookie = arch_phys_wc_add(rinfo->fb_base_phys,
2364 rinfo->video_ram, 2358 rinfo->video_ram);
2365 MTRR_TYPE_WRCOMB, 1);
2366#endif
2367 2359
2368 if (backlight) 2360 if (backlight)
2369 radeonfb_bl_init(rinfo); 2361 radeonfb_bl_init(rinfo);
@@ -2428,12 +2420,7 @@ static void radeonfb_pci_unregister(struct pci_dev *pdev)
2428 #endif 2420 #endif
2429 2421
2430 del_timer_sync(&rinfo->lvds_timer); 2422 del_timer_sync(&rinfo->lvds_timer);
2431 2423 arch_phys_wc_del(rinfo->wc_cookie);
2432#ifdef CONFIG_MTRR
2433 if (rinfo->mtrr_hdl >= 0)
2434 mtrr_del(rinfo->mtrr_hdl, 0, 0);
2435#endif
2436
2437 unregister_framebuffer(info); 2424 unregister_framebuffer(info);
2438 2425
2439 radeonfb_bl_exit(rinfo); 2426 radeonfb_bl_exit(rinfo);
@@ -2489,10 +2476,8 @@ static int __init radeonfb_setup (char *options)
2489 panel_yres = simple_strtoul((this_opt+11), NULL, 0); 2476 panel_yres = simple_strtoul((this_opt+11), NULL, 0);
2490 } else if (!strncmp(this_opt, "backlight:", 10)) { 2477 } else if (!strncmp(this_opt, "backlight:", 10)) {
2491 backlight = simple_strtoul(this_opt+10, NULL, 0); 2478 backlight = simple_strtoul(this_opt+10, NULL, 0);
2492#ifdef CONFIG_MTRR
2493 } else if (!strncmp(this_opt, "nomtrr", 6)) { 2479 } else if (!strncmp(this_opt, "nomtrr", 6)) {
2494 nomtrr = 1; 2480 nomtrr = 1;
2495#endif
2496 } else if (!strncmp(this_opt, "nomodeset", 9)) { 2481 } else if (!strncmp(this_opt, "nomodeset", 9)) {
2497 nomodeset = 1; 2482 nomodeset = 1;
2498 } else if (!strncmp(this_opt, "force_measure_pll", 17)) { 2483 } else if (!strncmp(this_opt, "force_measure_pll", 17)) {
@@ -2552,10 +2537,8 @@ module_param(monitor_layout, charp, 0);
2552MODULE_PARM_DESC(monitor_layout, "Specify monitor mapping (like XFree86)"); 2537MODULE_PARM_DESC(monitor_layout, "Specify monitor mapping (like XFree86)");
2553module_param(force_measure_pll, bool, 0); 2538module_param(force_measure_pll, bool, 0);
2554MODULE_PARM_DESC(force_measure_pll, "Force measurement of PLL (debug)"); 2539MODULE_PARM_DESC(force_measure_pll, "Force measurement of PLL (debug)");
2555#ifdef CONFIG_MTRR
2556module_param(nomtrr, bool, 0); 2540module_param(nomtrr, bool, 0);
2557MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers"); 2541MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers");
2558#endif
2559module_param(panel_yres, int, 0); 2542module_param(panel_yres, int, 0);
2560MODULE_PARM_DESC(panel_yres, "int: set panel yres"); 2543MODULE_PARM_DESC(panel_yres, "int: set panel yres");
2561module_param(mode_option, charp, 0); 2544module_param(mode_option, charp, 0);
diff --git a/drivers/video/fbdev/aty/radeonfb.h b/drivers/video/fbdev/aty/radeonfb.h
index 039def41c920..5bc1944ea1a9 100644
--- a/drivers/video/fbdev/aty/radeonfb.h
+++ b/drivers/video/fbdev/aty/radeonfb.h
@@ -340,7 +340,7 @@ struct radeonfb_info {
340 340
341 struct pll_info pll; 341 struct pll_info pll;
342 342
343 int mtrr_hdl; 343 int wc_cookie;
344 344
345 u32 save_regs[100]; 345 u32 save_regs[100];
346 int asleep; 346 int asleep;