x86/mm changes for v4.3
Subsystems (12)
Linus,
Please pull the latest x86-mm-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-mm-for-linus
# HEAD: 2baa891e42d84159b693eadd44f6fe1486285bdc x86/mm/mtrr: Remove kernel internal MTRR interfaces: unexport mtrr_add() and mtrr_del()
The dominant change in this cycle was the continued work to isolate kernel drivers from MTRR legacies: this tree gets rid of all kernel internal driver interfaces to MTRRs (mostly by rewriting it to proper PAT interfaces), the only access left is the /proc/mtrr ABI.
This work was done by Luis R. Rodriguez.
There's also some related PCI interface additions for which I've Cc:-ed Bjorn.
out-of-topic modifications in x86-mm-for-linus:
-------------------------------------------------
arch/avr32/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/frv/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/m32r/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/m68k/include/asm/io_mm.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/mn10300/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/powerpc/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/s390/include/asm/io.h # ee03c5868e74: s390/io: Add pci_iomap_wc()
arch/sh/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
arch/tile/include/asm/io.h # 4c73e8926623: arch/*/io.h: Add ioremap_uc(
drivers/dma/iop-adma.c # 39c33704420b: drivers/dma/iop-adma: Use dm
drivers/pci/pci.c # c43996f4001d: PCI: Add pci_ioremap_wc_bar(
drivers/video/fbdev/arkfb.c # c823a48ac47f: drivers/video/fbdev/arkfb.c:
drivers/video/fbdev/aty/atyfb.h # 7d89a3cb159a: drivers/video/fbdev/atyfb: U
# 3cc2dac5be3f: drivers/video/fbdev/atyfb: R
drivers/video/fbdev/aty/atyfb_base.c# 7d89a3cb159a: drivers/video/fbdev/atyfb: U
# 3cc2dac5be3f: drivers/video/fbdev/atyfb: R
# f55de6ec375d: drivers/video/fbdev/atyfb: C
# eacd2d542610: drivers/video/fbdev/atyfb: C
drivers/video/fbdev/gxt4500.c # f3adccbd7583: drivers/video/fbdev/gxt4500:
drivers/video/fbdev/i740fb.c # c112709809b2: drivers/video/fbdev/i740fb:
drivers/video/fbdev/kyro/fbdev.c # 9e517ac88b24: drivers/video/fbdev/kyrofb:
drivers/video/fbdev/s3fb.c # 4edcd2ab1255: drivers/video/fbdev/s3fb: Us
drivers/video/fbdev/vt8623fb.c # 81bdef04d3bc: drivers/video/fbdev/vt8623fb
include/asm-generic/io.h # 8c7ea50c010b: x86/mm, asm-generic: Add IOM
include/asm-generic/pci_iomap.h # 1b3d4200c1e0: PCI: Add pci_iomap_wc() vari
include/linux/pci.h # c43996f4001d: PCI: Add pci_ioremap_wc_bar(
include/video/kyro.h # 9e517ac88b24: drivers/video/fbdev/kyrofb:
lib/pci_iomap.c # 1b3d4200c1e0: PCI: Add pci_iomap_wc() variThanks,
Ingo
------------------>
Luis R. Rodriguez (17):
x86/mm, asm-generic: Add IOMMU ioremap_uc() variant default drivers/video/fbdev/atyfb: Carve out framebuffer length fudging into a helper drivers/video/fbdev/atyfb: Clarify ioremap() base and length used drivers/video/fbdev/atyfb: Replace MTRR UC hole with strong UC drivers/video/fbdev/atyfb: Use arch_phys_wc_add() and ioremap_wc() arch/*/io.h: Add ioremap_uc() to all architectures
PCI: Add pci_ioremap_wc_bar()
drivers/video/fbdev/i740fb: Use arch_phys_wc_add() and pci_ioremap_wc_bar() drivers/video/fbdev/kyrofb: Use arch_phys_wc_add() and pci_ioremap_wc_bar() drivers/video/fbdev/gxt4500: Use pci_ioremap_wc_bar() to map framebuffer
PCI: Add pci_iomap_wc() variants
drivers/video/fbdev/arkfb.c: Use arch_phys_wc_add() and pci_iomap_wc() drivers/video/fbdev/s3fb: Use arch_phys_wc_add() and pci_iomap_wc() drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc() drivers/dma/iop-adma: Use dma_alloc_writecombine() kernel-style
s390/io: Add pci_iomap_wc() and pci_iomap_wc_range()
x86/mm/mtrr: Remove kernel internal MTRR interfaces: unexport mtrr_add() and mtrr_del()
Minfei Huang (1):
x86/mm: Initialize pmd_idx in page_table_range_init_count()
Paul Gortmaker (2):
x86/mm/pat: Make mm/pageattr[-test].c explicitly non-modular x86/mm: Make kernel/check.c explicitly non-modular
Toshi Kani (1):
x86/mm/pat: Add comments to cachemode translation tables
Documentation/x86/mtrr.txt | 20 +++++-- arch/avr32/include/asm/io.h | 1 + arch/frv/include/asm/io.h | 1 + arch/m32r/include/asm/io.h | 1 + arch/m68k/include/asm/io_mm.h | 1 + arch/mn10300/include/asm/io.h | 1 + arch/powerpc/include/asm/io.h | 1 + arch/s390/include/asm/io.h | 2 + arch/sh/include/asm/io.h | 1 + arch/tile/include/asm/io.h | 1 + arch/x86/include/asm/io.h | 2 + arch/x86/kernel/check.c | 5 +- arch/x86/kernel/cpu/mtrr/main.c | 2 - arch/x86/mm/init.c | 7 ++- arch/x86/mm/init_32.c | 1 + arch/x86/mm/pageattr-test.c | 4 +- arch/x86/mm/pageattr.c | 1 - drivers/dma/iop-adma.c | 9 +-- drivers/pci/pci.c | 14 +++++ drivers/video/fbdev/arkfb.c | 36 ++---------- drivers/video/fbdev/aty/atyfb.h | 5 +- drivers/video/fbdev/aty/atyfb_base.c | 109 ++++++++++++++++------------------- drivers/video/fbdev/gxt4500.c | 2 +- drivers/video/fbdev/i740fb.c | 35 ++--------- drivers/video/fbdev/kyro/fbdev.c | 33 ++++------- drivers/video/fbdev/s3fb.c | 35 ++--------- drivers/video/fbdev/vt8623fb.c | 31 ++-------- include/asm-generic/io.h | 30 +++++++++- include/asm-generic/pci_iomap.h | 14 +++++ include/linux/pci.h | 1 + include/video/kyro.h | 4 +- lib/pci_iomap.c | 66 +++++++++++++++++++++ 32 files changed, 254 insertions(+), 222 deletions(-)
Documentation/x86/mtrr.txt +16 -4
@@ -6,10 +6,22 @@ Luis R. Rodriguez <[email protected]> - April 9, 2015 =============================================================================== Phasing out MTRR use -MTRR use is replaced on modern x86 hardware with PAT. Over time the only type -of effective MTRR that is expected to be supported will be for write-combining. -As MTRR use is phased out device drivers should use arch_phys_wc_add() to make -MTRR effective on non-PAT systems while a no-op on PAT enabled systems. +MTRR use is replaced on modern x86 hardware with PAT. Direct MTRR use by +drivers on Linux is now completely phased out, device drivers should use +arch_phys_wc_add() in combination with ioremap_wc() to make MTRR effective on +non-PAT systems while a no-op but equally effective on PAT enabled systems. + +Even if Linux does not use MTRRs directly, some x86 platform firmware may still +set up MTRRs early before booting the OS. They do this as some platform +firmware may still have implemented access to MTRRs which would be controlled +and handled by the platform firmware directly. An example of platform use of +MTRRs is through the use of SMI handlers, one case could be for fan control, +the platform code would need uncachable access to some of its fan control +registers. Such platform access does not need any Operating System MTRR code in +place other than mtrr_type_lookup() to ensure any OS specific mapping requests +are aligned with platform MTRR setup. If MTRRs are only set up by the platform +firmware code though and the OS does not make any specific MTRR mapping +requests mtrr_type_lookup() should always return MTRR_TYPE_INVALID. For details refer to Documentation/x86/pat.txt.
arch/avr32/include/asm/io.h +1 -0
@@ -297,6 +297,7 @@ extern void __iounmap(void __iomem *addr);#define ioremap_wc ioremap_nocache#define ioremap_wt ioremap_nocache +#define ioremap_uc ioremap_nocache#define cached (addr) P1SEGADDR(addr)#define uncached (addr) P2SEGADDR(addr)
arch/frv/include/asm/io.h +1 -0
@@ -278,6 +278,7 @@ static inline void __iomem *ioremap_fullcache(unsigned long physaddr, unsigned l }#define ioremap_wc ioremap_nocache +#define ioremap_uc ioremap_nocacheextern void iounmap (void volatile __iomem *addr);
arch/m32r/include/asm/io.h +1 -0
@@ -69,6 +69,7 @@ extern void iounmap(volatile void __iomem *addr);#define ioremap_nocache (off,size) ioremap(off,size)#define ioremap_wc ioremap_nocache#define ioremap_wt ioremap_nocache +#define ioremap_uc ioremap_nocache/* * IO bus memory addresses are also 1:1 with the physical address
arch/m68k/include/asm/io_mm.h +1 -0
@@ -468,6 +468,7 @@ static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned lon {return __ioremap (physaddr, size,IOMAP_NOCACHE_SER ); } +#define ioremap_uc ioremap_nocachestatic inline void __iomem *ioremap_wt (unsigned long physaddr,unsigned long size) {
arch/mn10300/include/asm/io.h +1 -0
@@ -283,6 +283,7 @@ static inline void __iomem *ioremap_nocache(unsigned long offset, unsigned long#define ioremap_wc ioremap_nocache#define ioremap_wt ioremap_nocache +#define ioremap_uc ioremap_nocachestatic inline void iounmap (void __iomem *addr) {
arch/powerpc/include/asm/io.h +1 -0
@@ -721,6 +721,7 @@ extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, unsigned long flags);extern void __iomem *ioremap_wc (phys_addr_t address,unsigned long size);#define ioremap_nocache (addr, size) ioremap((addr), (size)) +#define ioremap_uc (addr, size) ioremap((addr), (size))extern void iounmap (volatile void __iomem *addr);
arch/s390/include/asm/io.h +2 -0
@@ -57,6 +57,8 @@ static inline void ioport_unmap(void __iomem *p)*/ #define pci_iomap pci_iomap#define pci_iounmap pci_iounmap +#define pci_iomap_wc pci_iomap +#define pci_iomap_wc_range pci_iomap_range#define memcpy_fromio (dst, src, count) zpci_memcpy_fromio(dst, src, count)#define memcpy_toio (dst, src, count) zpci_memcpy_toio(dst, src, count)
arch/sh/include/asm/io.h +1 -0
@@ -368,6 +368,7 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }#endif #define ioremap_nocache ioremap +#define ioremap_uc ioremap#define iounmap __iounmap/*
arch/tile/include/asm/io.h +1 -0
@@ -55,6 +55,7 @@ extern void iounmap(volatile void __iomem *addr);#define ioremap_nocache (physaddr, size) ioremap(physaddr, size)#define ioremap_wc (physaddr, size) ioremap(physaddr, size)#define ioremap_wt (physaddr, size) ioremap(physaddr, size) +#define ioremap_uc (physaddr, size) ioremap(physaddr, size)#define ioremap_fullcache (physaddr, size) ioremap(physaddr, size)#define mmiowb ()
arch/x86/include/asm/io.h +2 -0
@@ -180,6 +180,8 @@ static inline unsigned int isa_virt_to_bus(volatile void *address)*/ extern void __iomem *ioremap_nocache (resource_size_t offset,unsigned long size);extern void __iomem *ioremap_uc (resource_size_t offset,unsigned long size); +#define ioremap_uc ioremap_uc +extern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size);extern void __iomem *ioremap_prot (resource_size_t offset,unsigned long size,unsigned long prot_val);
arch/x86/kernel/check.c +2 -3
@@ -1,4 +1,4 @@ -#include <linux/module.h> +#include <linux/init.h> #include <linux/sched.h> #include <linux/kthread.h> #include <linux/workqueue.h>
@@ -163,6 +163,5 @@ static int start_periodic_check_for_corruption(void)schedule_delayed_work (&bios_check_work,0 );return 0 ; } - -module_init (start_periodic_check_for_corruption); +device_initcall (start_periodic_check_for_corruption);
arch/x86/kernel/cpu/mtrr/main.c +0 -2
@@ -448,7 +448,6 @@ int mtrr_add(unsigned long base, unsigned long size, unsigned int type,return mtrr_add_page (base >>PAGE_SHIFT , size >>PAGE_SHIFT , type, increment); } -EXPORT_SYMBOL (mtrr_add);/** * mtrr_del_page - delete a memory type region
@@ -537,7 +536,6 @@ int mtrr_del(int reg, unsigned long base, unsigned long size)return -EINVAL ;return mtrr_del_page (reg, base >>PAGE_SHIFT , size >>PAGE_SHIFT ); } -EXPORT_SYMBOL (mtrr_del);/** * arch_phys_wc_add - add a WC MTRR and handle errors if PAT is unavailable
arch/x86/mm/init.c +5 -2
@@ -30,8 +30,11 @@/* * Tables translating between page_cache_type_t and pte encoding. * -* Minimal supported modes are defined statically, they are modified -* during bootup if more supported cache modes are available. +* The default values are defined statically as minimal supported mode; +* WC and WT fall back to UC-. pat_init() updates these values to support +* more cache modes, WC and WT, when it is safe to do so. See pat_init() +* for the details. Note, __early_ioremap() used during early boot-time +* takes pgprot_t (pte encoding) and does not use these tables. * * Index into __cachemode2pte_tbl[] is the cachemode. *
arch/x86/mm/init_32.c +1 -0
@@ -137,6 +137,7 @@ page_table_range_init_count(unsigned long start, unsigned long end) vaddr = start; pgd_idx =pgd_index (vaddr); + pmd_idx =pmd_index (vaddr);for ( ; (pgd_idx <PTRS_PER_PGD ) && (vaddr != end); pgd_idx++) { for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
arch/x86/mm/pageattr-test.c +2 -2
@@ -8,6 +8,7 @@#include <linux/kthread.h> #include <linux/random.h> #include <linux/kernel.h> +#include <linux/init.h> #include <linux/mm.h> #include <linux/vmalloc.h>
@@ -256,5 +257,4 @@ static int start_pageattr_test(void)return 0 ; } - -module_init (start_pageattr_test); +device_initcall (start_pageattr_test);
arch/x86/mm/pageattr.c +0 -1
@@ -4,7 +4,6 @@*/ #include <linux/highmem.h> #include <linux/bootmem.h> -#include <linux/module.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/interrupt.h>
drivers/dma/iop-adma.c +5 -4
@@ -1300,10 +1300,11 @@ static int iop_adma_probe(struct platform_device *pdev)* note: writecombine gives slightly better performance, but * requires that we explicitly flush the writes */ -if ((adev->dma_desc_pool_virt =dma_alloc_writecombine (&pdev->dev, - plat_data->pool_size, - &adev->dma_desc_pool, -GFP_KERNEL )) ==NULL ) { + adev->dma_desc_pool_virt =dma_alloc_writecombine (&pdev->dev, + plat_data->pool_size, + &adev->dma_desc_pool, +GFP_KERNEL ); +if (!adev->dma_desc_pool_virt) { ret = -ENOMEM ; goto err_free_adev; }
drivers/pci/pci.c +14 -0
@@ -138,6 +138,20 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) return ioremap_nocache(res->start, resource_size(res)); }EXPORT_SYMBOL_GPL (pci_ioremap_bar); + +void __iomem *pci_ioremap_wc_bar (struct pci_dev *pdev,int bar) +{ +/* +* Make sure the BAR is actually a memory resource, not an IO resource +*/ +if (!(pci_resource_flags (pdev, bar) &IORESOURCE_MEM )) { +WARN_ON (1 ); +return NULL ; + } +return ioremap_wc (pci_resource_start (pdev, bar), +pci_resource_len (pdev, bar)); +} +EXPORT_SYMBOL_GPL (pci_ioremap_wc_bar);#endif #define PCI_FIND_CAP_TTL 48
drivers/video/fbdev/arkfb.c +5 -31
@@ -26,13 +26,9 @@#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */ #include <video/vga.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif -struct arkfb_info {int mclk_freq; -int mtrr_reg; +int wc_cookie;struct dac_info *dac;struct vgastate state;
@@ -102,10 +98,6 @@ static const struct svga_timing_regs ark_timing_regs = {static char *mode_option ="640x480-8@60" ; -#ifdef CONFIG_MTRR -static int mtrr =1 ; -#endif -MODULE_AUTHOR ("(c) 2007 Ondrej Zajicek <[email protected]>" );MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("fbdev driver for ARK 2000PV" );
@@ -115,11 +107,6 @@ MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");module_param_named (mode, mode_option, charp,0444 );MODULE_PARM_DESC (mode,"Default video mode ('640x480-8@60', etc) (deprecated)" ); -#ifdef CONFIG_MTRR -module_param (mtrr, int,0444 ); -MODULE_PARM_DESC (mtrr,"Enable write-combining with MTRR (1=enable, 0=disable, default=1)" ); -#endif -static int threshold =4 ;module_param (threshold, int,0644 );
@@ -1002,7 +989,7 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) info->fix.smem_len =pci_resource_len (dev,0 );/* Map physical IO memory address into kernel space */ - info->screen_base =pci_iomap (dev,0 ,0 ); + info->screen_base =pci_iomap_wc (dev,0 ,0 );if (! info->screen_base) { rc = -ENOMEM ;dev_err (info->device,"iomap for framebuffer failed\n" );
@@ -1057,14 +1044,8 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)/* Record a reference to the driver data */ pci_set_drvdata (dev, info); - -#ifdef CONFIG_MTRR -if (mtrr) { - par->mtrr_reg =-1 ; - par->mtrr_reg =mtrr_add (info->fix.smem_start, info->fix.smem_len,MTRR_TYPE_WRCOMB ,1 ); - } -#endif - + par->wc_cookie =arch_phys_wc_add (info->fix.smem_start, + info->fix.smem_len);return 0 ;/* Error handling */
@@ -1092,14 +1073,7 @@ static void ark_pci_remove(struct pci_dev *dev)if (info) {struct arkfb_info *par = info->par; - -#ifdef CONFIG_MTRR -if (par->mtrr_reg >=0 ) { -mtrr_del (par->mtrr_reg,0 ,0 ); - par->mtrr_reg =-1 ; - } -#endif - +arch_phys_wc_del (par->wc_cookie);dac_release (par->dac);unregister_framebuffer (info);fb_dealloc_cmap (&info->cmap);
drivers/video/fbdev/aty/atyfb.h +1 -4
@@ -182,10 +182,7 @@ struct atyfb_par {unsigned long irq_flags;unsigned int irq;spinlock_t int_lock; -#ifdef CONFIG_MTRR -int mtrr_aper; -int mtrr_reg; -#endif +int wc_cookie;u32 mem_cntl;struct crtc saved_crtc;union aty_pll saved_pll;
drivers/video/fbdev/aty/atyfb_base.c +50 -59
191 lines not on this page · raw message
drivers/video/fbdev/gxt4500.c +1 -1
@@ -662,7 +662,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent) info->fix.smem_start = fb_phys; info->fix.smem_len =pci_resource_len (pdev,1 ); - info->screen_base =pci_ioremap_bar (pdev,1 ); + info->screen_base =pci_ioremap_wc_bar (pdev,1 );if (!info->screen_base) {dev_err (&pdev->dev,"gxt4500: cannot map framebuffer\n" ); goto err_unmap_regs;
drivers/video/fbdev/i740fb.c +6 -29
@@ -27,24 +27,15 @@#include <linux/console.h> #include <video/vga.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif -#include "i740_reg.h" static char *mode_option; - -#ifdef CONFIG_MTRR static int mtrr =1 ; -#endif struct i740fb_par {unsigned char __iomem *regs;bool has_sgram; -#ifdef CONFIG_MTRR -int mtrr_reg; -#endif +int wc_cookie;bool ddc_registered;struct i2c_adapter ddc_adapter;struct i2c_algo_bit_data ddc_algo;
@@ -1040,7 +1031,7 @@ static int i740fb_probe(struct pci_dev *dev, const struct pci_device_id *ent) goto err_request_regions; } - info->screen_base =pci_ioremap_bar (dev,0 ); + info->screen_base =pci_ioremap_wc_bar (dev,0 );if (!info->screen_base) {dev_err (info->device,"error remapping base\n" ); ret = -ENOMEM ;
@@ -1144,13 +1135,9 @@ static int i740fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)fb_info (info,"%s frame buffer device\n" , info->fix.id);pci_set_drvdata (dev, info); -#ifdef CONFIG_MTRR -if (mtrr) { - par->mtrr_reg =-1 ; - par->mtrr_reg =mtrr_add (info->fix.smem_start, - info->fix.smem_len,MTRR_TYPE_WRCOMB ,1 ); - } -#endif +if (mtrr) + par->wc_cookie =arch_phys_wc_add (info->fix.smem_start, + info->fix.smem_len);return 0 ; err_reg_framebuffer:
@@ -1177,13 +1164,7 @@ static void i740fb_remove(struct pci_dev *dev)if (info) {struct i740fb_par *par = info->par; - -#ifdef CONFIG_MTRR -if (par->mtrr_reg >=0 ) { -mtrr_del (par->mtrr_reg,0 ,0 ); - par->mtrr_reg =-1 ; - } -#endif +arch_phys_wc_del (par->wc_cookie);unregister_framebuffer (info);fb_dealloc_cmap (&info->cmap);if (par->ddc_registered)
@@ -1287,10 +1268,8 @@ static int __init i740fb_setup(char *options)while ((opt =strsep (&options,"," )) !=NULL ) {if (!*opt)continue ; -#ifdef CONFIG_MTRR else if (!strncmp (opt,"mtrr:" ,5 )) mtrr =simple_strtoul (opt +5 ,NULL ,0 ); -#endif else mode_option = opt; }
@@ -1327,7 +1306,5 @@ MODULE_DESCRIPTION("fbdev driver for Intel740");module_param (mode_option, charp,0444 );MODULE_PARM_DESC (mode_option,"Default video mode ('640x480-8@60', etc)" ); -#ifdef CONFIG_MTRR module_param (mtrr, int,0444 );MODULE_PARM_DESC (mtrr,"Enable write-combining with MTRR (1=enable, 0=disable, default=1)" ); -#endif
drivers/video/fbdev/kyro/fbdev.c +11 -22
@@ -22,9 +22,6 @@#include <linux/pci.h> #include <asm/io.h> #include <linux/uaccess.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #include <video/kyro.h>
@@ -84,9 +81,7 @@ static device_info_t deviceInfo;static char *mode_option =NULL ;static int nopan =0 ;static int nowrap =1 ; -#ifdef CONFIG_MTRR static int nomtrr =0 ; -#endif /* PCI driver prototypes */ static int kyrofb_probe (struct pci_dev *pdev,const struct pci_device_id *ent);
@@ -570,10 +565,8 @@ static int __init kyrofb_setup(char *options) nopan =1 ; }else if (strcmp (this_opt,"nowrap" ) ==0 ) { nowrap =1 ; -#ifdef CONFIG_MTRR }else if (strcmp (this_opt,"nomtrr" ) ==0 ) { nomtrr =1 ; -#endif }else { mode_option = this_opt; }
@@ -691,17 +684,16 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) currentpar->regbase = deviceInfo.pSTGReg =ioremap_nocache (kyro_fix.mmio_start, kyro_fix.mmio_len); +if (!currentpar->regbase) + goto out_free_fb; - info->screen_base =ioremap_nocache (kyro_fix.smem_start, - kyro_fix.smem_len); + info->screen_base =pci_ioremap_wc_bar (pdev,0 ); +if (!info->screen_base) + goto out_unmap_regs; -#ifdef CONFIG_MTRR if (!nomtrr) - currentpar->mtrr_handle = -mtrr_add (kyro_fix.smem_start, - kyro_fix.smem_len, -MTRR_TYPE_WRCOMB ,1 ); -#endif + currentpar->wc_cookie =arch_phys_wc_add (kyro_fix.smem_start, + kyro_fix.smem_len); kyro_fix.ypanstep = nopan ?0 :1 ; kyro_fix.ywrapstep = nowrap ?0 :1 ;
@@ -745,8 +737,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return 0 ; out_unmap: -iounmap (currentpar->regbase);iounmap (info->screen_base); +out_unmap_regs: +iounmap (currentpar->regbase); +out_free_fb:framebuffer_release (info);return -EINVAL ;
@@ -770,12 +764,7 @@ static void kyrofb_remove(struct pci_dev *pdev)iounmap (info->screen_base);iounmap (par->regbase); -#ifdef CONFIG_MTRR -if (par->mtrr_handle) -mtrr_del (par->mtrr_handle, - info->fix.smem_start, - info->fix.smem_len); -#endif +arch_phys_wc_del (par->wc_cookie);unregister_framebuffer (info);framebuffer_release (info);
drivers/video/fbdev/s3fb.c +6 -29
@@ -28,13 +28,9 @@#include <linux/i2c.h> #include <linux/i2c-algo-bit.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif -struct s3fb_info {int chip, rev, mclk_freq; -int mtrr_reg; +int wc_cookie;struct vgastate state;struct mutex open_lock;unsigned int ref_count;
@@ -154,11 +150,7 @@ static const struct svga_timing_regs s3_timing_regs = {static char *mode_option; - -#ifdef CONFIG_MTRR static int mtrr =1 ; -#endif -static int fasttext =1 ;
@@ -170,11 +162,8 @@ module_param(mode_option, charp, 0444);MODULE_PARM_DESC (mode_option,"Default video mode ('640x480-8@60', etc)" );module_param_named (mode, mode_option, charp,0444 );MODULE_PARM_DESC (mode,"Default video mode ('640x480-8@60', etc) (deprecated)" ); - -#ifdef CONFIG_MTRR module_param (mtrr, int,0444 );MODULE_PARM_DESC (mtrr,"Enable write-combining with MTRR (1=enable, 0=disable, default=1)" ); -#endif module_param (fasttext, int,0644 );MODULE_PARM_DESC (fasttext,"Enable S3 fast text mode (1=enable, 0=disable, default=1)" );
@@ -1168,7 +1157,7 @@ static int s3_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) info->fix.smem_len =pci_resource_len (dev,0 );/* Map physical IO memory address into kernel space */ - info->screen_base =pci_iomap (dev,0 ,0 ); + info->screen_base =pci_iomap_wc (dev,0 ,0 );if (! info->screen_base) { rc = -ENOMEM ;dev_err (info->device,"iomap for framebuffer failed\n" );
@@ -1365,12 +1354,9 @@ static int s3_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)/* Record a reference to the driver data */ pci_set_drvdata (dev, info); -#ifdef CONFIG_MTRR -if (mtrr) { - par->mtrr_reg =-1 ; - par->mtrr_reg =mtrr_add (info->fix.smem_start, info->fix.smem_len,MTRR_TYPE_WRCOMB ,1 ); - } -#endif +if (mtrr) + par->wc_cookie =arch_phys_wc_add (info->fix.smem_start, + info->fix.smem_len);return 0 ;
@@ -1405,14 +1391,7 @@ static void s3_pci_remove(struct pci_dev *dev)if (info) { par = info->par; - -#ifdef CONFIG_MTRR -if (par->mtrr_reg >=0 ) { -mtrr_del (par->mtrr_reg,0 ,0 ); - par->mtrr_reg =-1 ; - } -#endif - +arch_phys_wc_del (par->wc_cookie);unregister_framebuffer (info);fb_dealloc_cmap (&info->cmap);
@@ -1551,10 +1530,8 @@ static int __init s3fb_setup(char *options)if (!*opt)continue ; -#ifdef CONFIG_MTRR else if (!strncmp (opt,"mtrr:" ,5 )) mtrr =simple_strtoul (opt +5 ,NULL ,0 ); -#endif else if (!strncmp (opt,"fasttext:" ,9 )) fasttext =simple_strtoul (opt +9 ,NULL ,0 );else
drivers/video/fbdev/vt8623fb.c +6 -25
@@ -26,13 +26,9 @@#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */ #include <video/vga.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif -struct vt8623fb_info {char __iomem *mmio_base; -int mtrr_reg; +int wc_cookie;struct vgastate state;struct mutex open_lock;unsigned int ref_count;
@@ -99,10 +95,7 @@ static struct svga_timing_regs vt8623_timing_regs = {/* Module parameters */ static char *mode_option ="640x480-8@60" ; - -#ifdef CONFIG_MTRR static int mtrr =1 ; -#endif MODULE_AUTHOR ("(c) 2006 Ondrej Zajicek <[email protected]>" );MODULE_LICENSE ("GPL" );
@@ -112,11 +105,8 @@ module_param(mode_option, charp, 0644);MODULE_PARM_DESC (mode_option,"Default video mode ('640x480-8@60', etc)" );module_param_named (mode, mode_option, charp,0 );MODULE_PARM_DESC (mode,"Default video mode e.g. '648x480-8@60' (deprecated)" ); - -#ifdef CONFIG_MTRR module_param (mtrr, int,0444 );MODULE_PARM_DESC (mtrr,"Enable write-combining with MTRR (1=enable, 0=disable, default=1)" ); -#endif /* ------------------------------------------------------------------------- */
@@ -710,7 +700,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) info->fix.mmio_len =pci_resource_len (dev,1 );/* Map physical IO memory address into kernel space */ - info->screen_base =pci_iomap (dev,0 ,0 ); + info->screen_base =pci_iomap_wc (dev,0 ,0 );if (! info->screen_base) { rc = -ENOMEM ;dev_err (info->device,"iomap for framebuffer failed\n" );
@@ -781,12 +771,9 @@ static int vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)/* Record a reference to the driver data */ pci_set_drvdata (dev, info); -#ifdef CONFIG_MTRR -if (mtrr) { - par->mtrr_reg =-1 ; - par->mtrr_reg =mtrr_add (info->fix.smem_start, info->fix.smem_len,MTRR_TYPE_WRCOMB ,1 ); - } -#endif +if (mtrr) + par->wc_cookie =arch_phys_wc_add (info->fix.smem_start, + info->fix.smem_len);return 0 ;
@@ -816,13 +803,7 @@ static void vt8623_pci_remove(struct pci_dev *dev)if (info) {struct vt8623fb_info *par = info->par; -#ifdef CONFIG_MTRR -if (par->mtrr_reg >=0 ) { -mtrr_del (par->mtrr_reg,0 ,0 ); - par->mtrr_reg =-1 ; - } -#endif - +arch_phys_wc_del (par->wc_cookie);unregister_framebuffer (info);fb_dealloc_cmap (&info->cmap);
include/asm-generic/io.h +29 -1
@@ -736,6 +736,35 @@ static inline void *phys_to_virt(unsigned long address) }#endif +/** +* DOC: ioremap() and ioremap_*() variants +* +* If you have an IOMMU your architecture is expected to have both ioremap() +* and iounmap() implemented otherwise the asm-generic helpers will provide a +* direct mapping. +* +* There are ioremap_*() call variants, if you have no IOMMU we naturally will +* default to direct mapping for all of them, you can override these defaults. +* If you have an IOMMU you are highly encouraged to provide your own +* ioremap variant implementation as there currently is no safe architecture +* agnostic default. To avoid possible improper behaviour default asm-generic +* ioremap_*() variants all return NULL when an IOMMU is available. If you've +* defined your own ioremap_*() variant you must then declare your own +* ioremap_*() variant as defined to itself to avoid the default NULL return. +*/ + +#ifdef CONFIG_MMU + +#ifndef ioremap_uc +#define ioremap_uc ioremap_uc +static inline void __iomem *ioremap_uc (phys_addr_t offset,size_t size) +{ +return NULL ; +} +#endif + +#else /* !CONFIG_MMU */ +/* * Change "struct page" to physical address. *
@@ -743,7 +772,6 @@ static inline void *phys_to_virt(unsigned long address)* you'll need to provide your own definitions. */ -#ifndef CONFIG_MMU #ifndef ioremap#define ioremap ioremapstatic inline void __iomem *ioremap (phys_addr_t offset,size_t size)
include/asm-generic/pci_iomap.h +14 -0
@@ -15,9 +15,13 @@ struct pci_dev;#ifdef CONFIG_PCI /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ extern void __iomem *pci_iomap (struct pci_dev *dev,int bar,unsigned long max); +extern void __iomem *pci_iomap_wc (struct pci_dev *dev,int bar,unsigned long max);extern void __iomem *pci_iomap_range (struct pci_dev *dev,int bar,unsigned long offset,unsigned long maxlen); +extern void __iomem *pci_iomap_wc_range (struct pci_dev *dev,int bar, +unsigned long offset, +unsigned long maxlen);/* Create a virtual mapping cookie for a port on a given PCI device. * Do not call this directly, it exists to make it easier for architectures * to override */
@@ -34,12 +38,22 @@ static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned lonreturn NULL ; } +static inline void __iomem *pci_iomap_wc (struct pci_dev *dev,int bar,unsigned long max) +{ +return NULL ; +}static inline void __iomem *pci_iomap_range (struct pci_dev *dev,int bar,unsigned long offset,unsigned long maxlen) {return NULL ; } +static inline void __iomem *pci_iomap_wc_range (struct pci_dev *dev,int bar, +unsigned long offset, +unsigned long maxlen) +{ +return NULL ; +}#endif #endif /* __ASM_GENERIC_IO_H */
include/linux/pci.h +1 -0
@@ -1661,6 +1661,7 @@ static inline void pci_mmcfg_late_init(void) { }int pci_ext_cfg_avail (void );void __iomem *pci_ioremap_bar (struct pci_dev *pdev,int bar); +void __iomem *pci_ioremap_wc_bar (struct pci_dev *pdev,int bar);#ifdef CONFIG_PCI_IOV int pci_iov_virtfn_bus (struct pci_dev *dev,int id);
include/video/kyro.h +1 -3
@@ -35,9 +35,7 @@ struct kyrofb_info {/* Useful to hold depth here for Linux */ u8 PIXDEPTH ; -#ifdef CONFIG_MTRR -int mtrr_handle; -#endif +int wc_cookie; };extern int kyro_dev_init (void );
lib/pci_iomap.c +66 -0
76 lines not on this page · raw message