diff options
author | Luis R. Rodriguez <mcgrof@suse.com> | 2015-07-09 21:24:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-07-21 04:47:05 -0400 |
commit | 7d89a3cb159aecb1b363ea50cb14c967ff83b5a6 (patch) | |
tree | 9093e1e4f0854b45b6b0443630c31cb849cd6adc | |
parent | 3cc2dac5be3f23414a4efdee0b26d79bed297cac (diff) |
drivers/video/fbdev/atyfb: Use arch_phys_wc_add() and ioremap_wc()
This driver uses strong UC for the MMIO region, and ioremap_wc()
for the framebuffer to whitelist for the WC MTRR that can be
changed to WC. On PAT systems we don't need the MTRR call so
just use arch_phys_wc_add() there, this lets us remove all those
ifdefs. Let's also be consistent and use ioremap_wc() for ATARI
as well.
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 it is being 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 ifdeffery 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);
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathias Krause <minipli@googlemail.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: arnd@arndb.de
Cc: benh@kernel.crashing.org
Cc: dan.j.williams@intel.com
Cc: geert@linux-m68k.org
Cc: hch@lst.de
Cc: hmh@hmh.eng.br
Cc: linux-fbdev@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-pci@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: mst@redhat.com
Cc: ralf@linux-mips.org
Cc: ross.zwisler@linux.intel.com
Cc: stefan.bader@canonical.com
Cc: tj@kernel.org
Cc: ville.syrjala@linux.intel.com
Link: http://lkml.kernel.org/r/1436491499-3289-5-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | drivers/video/fbdev/aty/atyfb.h | 4 | ||||
-rw-r--r-- | drivers/video/fbdev/aty/atyfb_base.c | 36 |
2 files changed, 8 insertions, 32 deletions
diff --git a/drivers/video/fbdev/aty/atyfb.h b/drivers/video/fbdev/aty/atyfb.h index 89ec4398d201..63c4842eb224 100644 --- a/drivers/video/fbdev/aty/atyfb.h +++ b/drivers/video/fbdev/aty/atyfb.h | |||
@@ -182,9 +182,7 @@ struct atyfb_par { | |||
182 | unsigned long irq_flags; | 182 | unsigned long irq_flags; |
183 | unsigned int irq; | 183 | unsigned int irq; |
184 | spinlock_t int_lock; | 184 | spinlock_t int_lock; |
185 | #ifdef CONFIG_MTRR | 185 | int wc_cookie; |
186 | int mtrr_aper; | ||
187 | #endif | ||
188 | u32 mem_cntl; | 186 | u32 mem_cntl; |
189 | struct crtc saved_crtc; | 187 | struct crtc saved_crtc; |
190 | union aty_pll saved_pll; | 188 | union aty_pll saved_pll; |
diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index 7770a8485fb5..f34ed47fcaf8 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c | |||
@@ -98,9 +98,6 @@ | |||
98 | #ifdef CONFIG_PMAC_BACKLIGHT | 98 | #ifdef CONFIG_PMAC_BACKLIGHT |
99 | #include <asm/backlight.h> | 99 | #include <asm/backlight.h> |
100 | #endif | 100 | #endif |
101 | #ifdef CONFIG_MTRR | ||
102 | #include <asm/mtrr.h> | ||
103 | #endif | ||
104 | 101 | ||
105 | /* | 102 | /* |
106 | * Debug flags. | 103 | * Debug flags. |
@@ -303,9 +300,7 @@ static struct fb_ops atyfb_ops = { | |||
303 | }; | 300 | }; |
304 | 301 | ||
305 | static bool noaccel; | 302 | static bool noaccel; |
306 | #ifdef CONFIG_MTRR | ||
307 | static bool nomtrr; | 303 | static bool nomtrr; |
308 | #endif | ||
309 | static int vram; | 304 | static int vram; |
310 | static int pll; | 305 | static int pll; |
311 | static int mclk; | 306 | static int mclk; |
@@ -2628,17 +2623,13 @@ static int aty_init(struct fb_info *info) | |||
2628 | aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | | 2623 | aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | |
2629 | BUS_APER_REG_DIS, par); | 2624 | BUS_APER_REG_DIS, par); |
2630 | 2625 | ||
2631 | #ifdef CONFIG_MTRR | 2626 | if (!nomtrr) |
2632 | par->mtrr_aper = -1; | ||
2633 | if (!nomtrr) { | ||
2634 | /* | 2627 | /* |
2635 | * Only the ioremap_wc()'d area will get WC here | 2628 | * Only the ioremap_wc()'d area will get WC here |
2636 | * since ioremap_uc() was used on the entire PCI BAR. | 2629 | * since ioremap_uc() was used on the entire PCI BAR. |
2637 | */ | 2630 | */ |
2638 | par->mtrr_aper = mtrr_add(par->res_start, par->res_size, | 2631 | par->wc_cookie = arch_phys_wc_add(par->res_start, |
2639 | MTRR_TYPE_WRCOMB, 1); | 2632 | par->res_size); |
2640 | } | ||
2641 | #endif | ||
2642 | 2633 | ||
2643 | info->fbops = &atyfb_ops; | 2634 | info->fbops = &atyfb_ops; |
2644 | info->pseudo_palette = par->pseudo_palette; | 2635 | info->pseudo_palette = par->pseudo_palette; |
@@ -2766,13 +2757,8 @@ aty_init_exit: | |||
2766 | /* restore video mode */ | 2757 | /* restore video mode */ |
2767 | aty_set_crtc(par, &par->saved_crtc); | 2758 | aty_set_crtc(par, &par->saved_crtc); |
2768 | par->pll_ops->set_pll(info, &par->saved_pll); | 2759 | par->pll_ops->set_pll(info, &par->saved_pll); |
2760 | arch_phys_wc_del(par->wc_cookie); | ||
2769 | 2761 | ||
2770 | #ifdef CONFIG_MTRR | ||
2771 | if (par->mtrr_aper >= 0) { | ||
2772 | mtrr_del(par->mtrr_aper, 0, 0); | ||
2773 | par->mtrr_aper = -1; | ||
2774 | } | ||
2775 | #endif | ||
2776 | return ret; | 2762 | return ret; |
2777 | } | 2763 | } |
2778 | 2764 | ||
@@ -3672,7 +3658,8 @@ static int __init atyfb_atari_probe(void) | |||
3672 | * Map the video memory (physical address given) | 3658 | * Map the video memory (physical address given) |
3673 | * to somewhere in the kernel address space. | 3659 | * to somewhere in the kernel address space. |
3674 | */ | 3660 | */ |
3675 | info->screen_base = ioremap(phys_vmembase[m64_num], phys_size[m64_num]); | 3661 | info->screen_base = ioremap_wc(phys_vmembase[m64_num], |
3662 | phys_size[m64_num]); | ||
3676 | info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */ | 3663 | info->fix.smem_start = (unsigned long)info->screen_base; /* Fake! */ |
3677 | par->ati_regbase = ioremap(phys_guiregbase[m64_num], 0x10000) + | 3664 | par->ati_regbase = ioremap(phys_guiregbase[m64_num], 0x10000) + |
3678 | 0xFC00ul; | 3665 | 0xFC00ul; |
@@ -3738,13 +3725,8 @@ static void atyfb_remove(struct fb_info *info) | |||
3738 | if (M64_HAS(MOBIL_BUS)) | 3725 | if (M64_HAS(MOBIL_BUS)) |
3739 | aty_bl_exit(info->bl_dev); | 3726 | aty_bl_exit(info->bl_dev); |
3740 | #endif | 3727 | #endif |
3728 | arch_phys_wc_del(par->wc_cookie); | ||
3741 | 3729 | ||
3742 | #ifdef CONFIG_MTRR | ||
3743 | if (par->mtrr_aper >= 0) { | ||
3744 | mtrr_del(par->mtrr_aper, 0, 0); | ||
3745 | par->mtrr_aper = -1; | ||
3746 | } | ||
3747 | #endif | ||
3748 | #ifndef __sparc__ | 3730 | #ifndef __sparc__ |
3749 | if (par->ati_regbase) | 3731 | if (par->ati_regbase) |
3750 | iounmap(par->ati_regbase); | 3732 | iounmap(par->ati_regbase); |
@@ -3860,10 +3842,8 @@ static int __init atyfb_setup(char *options) | |||
3860 | while ((this_opt = strsep(&options, ",")) != NULL) { | 3842 | while ((this_opt = strsep(&options, ",")) != NULL) { |
3861 | if (!strncmp(this_opt, "noaccel", 7)) { | 3843 | if (!strncmp(this_opt, "noaccel", 7)) { |
3862 | noaccel = 1; | 3844 | noaccel = 1; |
3863 | #ifdef CONFIG_MTRR | ||
3864 | } else if (!strncmp(this_opt, "nomtrr", 6)) { | 3845 | } else if (!strncmp(this_opt, "nomtrr", 6)) { |
3865 | nomtrr = 1; | 3846 | nomtrr = 1; |
3866 | #endif | ||
3867 | } else if (!strncmp(this_opt, "vram:", 5)) | 3847 | } else if (!strncmp(this_opt, "vram:", 5)) |
3868 | vram = simple_strtoul(this_opt + 5, NULL, 0); | 3848 | vram = simple_strtoul(this_opt + 5, NULL, 0); |
3869 | else if (!strncmp(this_opt, "pll:", 4)) | 3849 | else if (!strncmp(this_opt, "pll:", 4)) |
@@ -4033,7 +4013,5 @@ module_param(comp_sync, int, 0); | |||
4033 | MODULE_PARM_DESC(comp_sync, "Set composite sync signal to low (0) or high (1)"); | 4013 | MODULE_PARM_DESC(comp_sync, "Set composite sync signal to low (0) or high (1)"); |
4034 | module_param(mode, charp, 0); | 4014 | module_param(mode, charp, 0); |
4035 | MODULE_PARM_DESC(mode, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); | 4015 | MODULE_PARM_DESC(mode, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); |
4036 | #ifdef CONFIG_MTRR | ||
4037 | module_param(nomtrr, bool, 0); | 4016 | module_param(nomtrr, bool, 0); |
4038 | MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers"); | 4017 | MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers"); |
4039 | #endif | ||