pci: add pci_iomap_wc() and pci_ioremap_wc_bar()
Subsystems (4)
v8 cover pci: add pci_iomap_wc() and pci_ioremap_wc_bar()
From: "Luis R. Rodriguez" <[email protected]>
Boris,
This patchset is part of the long haul of series that addresses removal of direct use of MTRR and transforms drivers over to use PAT interfaces when available [0]. Other than this series there is only one more pending series for that effort, the other one being the atyfb device driver specific changes which no one has replied to for over one month and I'll soon repost and hope that Andrew might pick up. The patches in this series were originally split in two series but I've combined them now given all Acks have been collected and they are all related. Tomi has provided his Acked-by for all device driver changes. Bjorn had originally reviewed this series and was comfortable with all the code except for the use of EXPORT_SYMBOL_GPL() despite new clarifications of how we can use this for new symbols and our preference for it on new PAT interfaces [1], despite this Bjorn has clarified he's comfortable with this going in through another maintainer and in particular Arnd [2]. The v7 series was posted addressing Arnd, Arnd provided his Acked-by for all PCI and devres changes but noted he's on parental leave and not taking any patches for arm-soc or asm-generic until he's back at work in around 3 months from now [2] so he suggested to see if I could find another maintainer to have these go through.
This v8 goes unmodified, except for the devres commit, since those routines are not yet used by any device driver for now I've just skipped exporting the symbols but did note that if they will be it must be exported with EXPORT_SYMBOL_GPL(). Once we have a driver need them upstream we can export these.
Although I had test compiled this before just to be safe I went ahead and successfully test-compiled this set with allmodconfig, specially since I've now removed the exports for the devres routines. Please let me know if these might be able to go through you or if there are any questions. I will note the recent discussion with Benjamin over the v7 series concluded that the ideas we both were alluding to, on automating instead the WC effects for devices seems a bit too idealistic for PCI / PCIE for now, but perhaps we should at least consider this in the future for userspace mmap() calls [4].
[0] http://lkml.kernel.org/r/CAB=NE6UgtdSoBsA=8+ueYRAZHDnWUSmQAoHhAaefqudBrSY7Zw@mail.gmail.com
[1] http://lkml.kernel.org/r/CAErSpo4sHA-f83X1nW2QdLT9GdubFXCQ7UEJmSfFc5GBjj8FSA@mail.gmail.com
[2] http://lkml.kernel.org/r/CAErSpo7CNH1WpgqJCEU8EtxiFNp_PiQ3cBwnKiWQpUaD-fd4YA@mail.gmail.com
[3] http://lkml.kernel.org/r/[email protected]
Luis R. Rodriguez (9):
pci: add pci_ioremap_wc_bar()
video: fbdev: i740fb: use arch_phys_wc_add() and pci_ioremap_wc_bar()
video: fbdev: kyrofb: use arch_phys_wc_add() and pci_ioremap_wc_bar()
video: fbdev: gxt4500: use pci_ioremap_wc_bar() for framebuffer
PCI: Add pci_iomap_wc() variants
lib: devres: add pcim_iomap_wc() variants
video: fbdev: arkfb: use arch_phys_wc_add() and pci_iomap_wc()
video: fbdev: s3fb: use arch_phys_wc_add() and pci_iomap_wc()
video: fbdev: vt8623fb: use arch_phys_wc_add() and pci_iomap_wc()
drivers/pci/pci.c | 14 ++++++++ drivers/video/fbdev/arkfb.c | 36 +++---------------- 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/pci_iomap.h | 14 ++++++++ include/linux/pci.h | 3 ++ include/video/kyro.h | 4 +-- lib/devres.c | 76 ++++++++++++++++++++++++++++++++++++++++ lib/pci_iomap.c | 61 ++++++++++++++++++++++++++++++++ 12 files changed, 204 insertions(+), 140 deletions(-)
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 1/9 pci: add pci_ioremap_wc_bar()
From: "Luis R. Rodriguez" <[email protected]>
This lets drivers take advantage of PAT when available. This should help with the transition of converting video drivers over to ioremap_wc() to help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()")
--- drivers/pci/pci.c | 14 ++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 15 insertions(+)
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
include/linux/pci.h +1 -0
@@ -1657,6 +1657,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);
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 2/9 video: fbdev: i740fb: use arch_phys_wc_add() and pci_ioremap_wc_bar()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
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);
--- drivers/video/fbdev/i740fb.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-)
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
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 3/9 video: fbdev: kyrofb: use arch_phys_wc_add() and pci_ioremap_wc_bar()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
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);
--- drivers/video/fbdev/kyro/fbdev.c | 33 +++++++++++---------------------- include/video/kyro.h | 4 +--- 2 files changed, 12 insertions(+), 25 deletions(-)
drivers/video/fbdev/kyro/fbdev.c +11 -21
@@ -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);
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 );
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 4/9 video: fbdev: gxt4500: use pci_ioremap_wc_bar() for framebuffer
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
The driver doesn't use mtrr_add() or arch_phys_wc_add() but since we know the framebuffer is isolated already on an ioremap() we can take advantage of write combining for performance where possible.
In this case there are a few motivations for this:
a) Take advantage of PAT when available
b) 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()")
--- drivers/video/fbdev/gxt4500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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;
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 5/9 PCI: Add pci_iomap_wc() variants
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
PCI BARs tell us whether prefetching is safe, but they don't say anything about write combining (WC). WC changes ordering rules and allows writes to be collapsed, so it's not safe in general to use it on a prefetchable region.
Add pci_iomap_wc() and pci_iomap_wc_range() so drivers can take advantage of write combining when they know it's safe.
On architectures that don't fully support WC, e.g., x86 without PAT, drivers for legacy framebuffers may get some of the benefit by using arch_phys_wc_add() in addition to pci_iomap_wc(). But arch_phys_wc_add() is unreliable and should be avoided in general. On x86, it uses MTRRs, which are limited in number and size, so the results will vary based on driver loading order.
The goals of adding pci_iomap_wc() are to:
- Give drivers an architecture-independent way to use WC so they can stop using interfaces like mtrr_add() (on x86, pci_iomap_wc() uses PAT when available)
- Move toward using _PAGE_CACHE_MODE_UC, not _PAGE_CACHE_MODE_UC_MINUS, on x86 on ioremap_nocache() (see de33c442ed2a ("x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()")
Original-posting: http://lkml.kernel.org/r/[email protected]
--- include/asm-generic/pci_iomap.h | 14 ++++++++++ lib/pci_iomap.c | 61 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)
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 */
lib/pci_iomap.c +61 -0
71 lines not on this page · raw message
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 6/9 lib: devres: add pcim_iomap_wc() variants
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Now that we have pci_iomap_wc() add the respective devres helpers. These go unexported for now but note that should they later be exported this must go with EXPORT_SYMBOL_GPL().
--- include/linux/pci.h | 2 ++ lib/devres.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
include/linux/pci.h +2 -0
@@ -1609,9 +1609,11 @@ static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }#endif void __iomem *pcim_iomap (struct pci_dev *pdev,int bar,unsigned long maxlen); +void __iomem *pcim_iomap_wc (struct pci_dev *pdev,int bar,unsigned long maxlen);void pcim_iounmap (struct pci_dev *pdev,void __iomem *addr);void __iomem *const *pcim_iomap_table (struct pci_dev *pdev);int pcim_iomap_regions (struct pci_dev *pdev,int mask,const char *name); +int pcim_iomap_wc_regions (struct pci_dev *pdev,int mask,const char *name);int pcim_iomap_regions_request_all (struct pci_dev *pdev,int mask,const char *name);void pcim_iounmap_regions (struct pci_dev *pdev,int mask);
lib/devres.c +76 -0
88 lines not on this page · raw message
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 7/9 video: fbdev: arkfb: use arch_phys_wc_add() and pci_iomap_wc()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
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);
--- drivers/video/fbdev/arkfb.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-)
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);
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 8/9 video: fbdev: s3fb: use arch_phys_wc_add() and pci_iomap_wc()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
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);
--- drivers/video/fbdev/s3fb.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-)
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
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
PATCH v8 9/9 video: fbdev: vt8623fb: use arch_phys_wc_add() and pci_iomap_wc()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
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);
--- drivers/video/fbdev/vt8623fb.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)
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);
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
Re: [PATCH v8 5/9] PCI: Add pci_iomap_wc() variants
In reply to Luis R. RodriguezQuoted 27 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
PCI BARs tell us whether prefetching is safe, but they don't say anything about write combining (WC). WC changes ordering rules and allows writes to be collapsed, so it's not safe in general to use it on a prefetchable region.
Add
pci_iomap_wc()andpci_iomap_wc_range()so drivers can take advantage of write combining when they know it's safe.On architectures that don't fully support WC, e.g., x86 without PAT, drivers for legacy framebuffers may get some of the benefit by using
arch_phys_wc_add()in addition topci_iomap_wc(). Butarch_phys_wc_add()is unreliable and should be avoided in general. On x86, it uses MTRRs, which are limited in number and size, so the results will vary based on driver loading order.The goals of adding
pci_iomap_wc()are to:- Give drivers an architecture-independent way to use WC so they can stop using interfaces like
mtrr_add()(on x86,pci_iomap_wc()uses PAT when available)- Move toward using
_PAGE_CACHE_MODE_UC, not_PAGE_CACHE_MODE_UC_MINUS, on x86 onioremap_nocache()(seede33c442ed2a("x86 PAT: fix performance drop for glx, use UC minus forioremap(),ioremap_nocache()andpci_mmap_page_range()")
...
Quoted 30 lines
lib/pci_iomap.c +22
-0@@ -52,6 +52,46 @@ void __iomem *pci_iomap_range(struct pci_dev *dev,EXPORT_SYMBOL (pci_iomap_range);/** +* pci_iomap_wc_range - create a virtual WC mapping cookie for a PCI BAR +* @dev: PCI device that owns the BAR +* @bar: BAR number +* @offset: map memory at the given offset in BAR +* @maxlen: max length of the memory to map +* +* Using this function you will get a __iomem address to your device BAR. +* You can access it using ioread*() and iowrite*(). These functions hide +* the details if this is a MMIO or PIO address space and will just do what +* you expect from them in the correct way. When possible write combining +* is used. +* +* @maxlen specifies the maximum length to map. If you want to get access to +* the complete BAR from offset to the end, pass %0 here. +* */ +void __iomem *pci_iomap_wc_range (struct pci_dev *dev, +int bar, +unsigned long offset, +unsigned long maxlen) +{ +resource_size_t start =pci_resource_start (dev, bar); +resource_size_t len =pci_resource_len (dev, bar);
lib/pci_iomap.c void __iomem *pci_iomap_range(struct pci_dev *dev, · line 86
Quoted 10 lines
lib/pci_iomap.c +10
-0+unsigned long flags =pci_resource_flags (dev, bar); + +if (len <= offset || !start) +return NULL ; + len -= offset; + start += offset; +if (maxlen && len > maxlen) + len = maxlen; +if (flags &IORESOURCE_IO ) +return NULL ;
I've moved this check at the beginning of the function so that we bail out before doing the computations above it.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH v8 6/9] lib: devres: add pcim_iomap_wc() variants
In reply to Luis R. RodriguezQuoted 6 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that we have
pci_iomap_wc()add the respective devres helpers. These go unexported for now but note that should they later be exported this must go withEXPORT_SYMBOL_GPL().
Do I see it correctly, those are not used in this patchset?
If so, then let's keep this patch in the bag and pick it up only when those functions have users.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH v8 6/9] lib: devres: add pcim_iomap_wc() variants
Quoted 9 lines · Borislav Petkov
Quoted 6 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that we have
pci_iomap_wc()add the respective devres helpers. These go unexported for now but note that should they later be exported this must go withEXPORT_SYMBOL_GPL().Do I see it correctly, those are not used in this patchset?
That's correct. It was a preemptive implementation of devres pci wc APIs.
Quoted 2 lines
If so, then let's keep this patch in the bag and pick it up only when those functions have users.
OK!
Luis
Re: [PATCH v8 5/9] PCI: Add pci_iomap_wc() variants
In reply to Borislav PetkovQuoted 12 lines · Borislav Petkov
Quoted 12 lines
lib/pci_iomap.c +12
-0+void __iomem *pci_iomap_wc_range (struct pci_dev *dev, +int bar, +unsigned long offset, +unsigned long maxlen) +{ +resource_size_t start =pci_resource_start (dev, bar); +resource_size_t len =pci_resource_len (dev, bar); +unsigned long flags =pci_resource_flags (dev, bar); + +if (len <= offset || !start) +return NULL ; + len -= offset;
Quoted 8 lines
lib/pci_iomap.c void __iomem *pci_iomap_range(struct pci_dev *dev, · line 86
Quoted 5 lines
lib/pci_iomap.c +5
-0+ start += offset; +if (maxlen && len > maxlen) + len = maxlen; +if (flags &IORESOURCE_IO ) +return NULL ;I've moved this check at the beginning of the function so that we bail out before doing the computations above it.
That indeed looks like a good optimization.
Luis
Quoted 11 lines · Luis R. Rodriguez
Luis R. Rodriguez (9):
pci: addpci_ioremap_wc_bar()
video: fbdev: i740fb: usearch_phys_wc_add()andpci_ioremap_wc_bar()
video: fbdev: kyrofb: usearch_phys_wc_add()andpci_ioremap_wc_bar()
video: fbdev: gxt4500: usepci_ioremap_wc_bar()for framebuffer
PCI: Addpci_iomap_wc()variants
lib: devres: addpcim_iomap_wc()variants
video: fbdev: arkfb: usearch_phys_wc_add()andpci_iomap_wc()
video: fbdev: s3fb: usearch_phys_wc_add()andpci_iomap_wc()
video: fbdev: vt8623fb: usearch_phys_wc_add()andpci_iomap_wc()
Quoted 13 lines
drivers/pci/pci.c | 14 ++++++++ drivers/video/fbdev/arkfb.c | 36 +++---------------- 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/pci_iomap.h | 14 ++++++++ include/linux/pci.h | 3 ++ include/video/kyro.h | 4 +-- lib/devres.c | 76 ++++++++++++++++++++++++++++++++++++++++ lib/pci_iomap.c | 61 ++++++++++++++++++++++++++++++++ 12 files changed, 204 insertions(+), 140 deletions(-)
Took those, modulo the devres one.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 8 lines · Luis R. Rodriguez
Although I had test compiled this before just to be safe I went ahead and successfully test-compiled this set with allmodconfig, specially since I've now removed the exports for the devres routines. Please let me know if these might be able to go through you or if there are any questions. I will note the recent discussion with Benjamin over the v7 series concluded that the ideas we both were alluding to, on automating instead the WC effects for devices seems a bit too idealistic for PCI / PCIE for now, but perhaps we should at least consider this in the future for userspace
mmap()calls [4].
So I've been trying to figure out how to make this practically work for us (powerpc).
writel() will never write combine for us, it uses too heavy barriers.
writel_relaxed() today is identical to writel() but we can change it.
The problem is that switching to G=0 mappings (which is what provides us with write combining) also architecturally enables prefetch and speculative loads... and again architecturally (the implementations may differ), kills the effect of the lightweight io barrier eieio which we would have to use in readl_relaxed() and writel_relaxed() to provide their normal semantics.
So it boils down to: Can we modify the documentation of readl_relaxed() and writel_relaxed() to define them as being even further relaxed when using a "wc" mapping ?
Otherwise, the only way out I see for us on powerpc is to bias massively writel_relaxed() against real_relaxed() by putting heavy barriers around the load in the latter so we can keep them completely out of the former and still enable wc.
Ben.
Quoted 22 lines · Benjamin Herrenschmidt
Quoted 8 lines · Luis R. Rodriguez
Although I had test compiled this before just to be safe I went ahead and successfully test-compiled this set with allmodconfig, specially since I've now removed the exports for the devres routines. Please let me know if these might be able to go through you or if there are any questions. I will note the recent discussion with Benjamin over the v7 series concluded that the ideas we both were alluding to, on automating instead the WC effects for devices seems a bit too idealistic for PCI / PCIE for now, but perhaps we should at least consider this in the future for userspace
mmap()calls [4].So I've been trying to figure out how to make this practically work for us (powerpc).
writel()will never write combine for us, it uses too heavy barriers.
writel_relaxed()today is identical towritel()but we can change it.The problem is that switching to G=0 mappings (which is what provides us with write combining) also architecturally enables prefetch and speculative loads... and again architecturally (the implementations may differ), kills the effect of the lightweight io barrier eieio which we would have to use in
readl_relaxed()andwritel_relaxed()to provide their normal semantics.
Quoted 6 lines
So it boils down to: Can we modify the documentation of
readl_relaxed()andwritel_relaxed()to define them as being even further relaxed when using a "wc" mapping ?Otherwise, the only way out I see for us on powerpc is to bias massively
writel_relaxed()againstreal_relaxed()by putting heavy barriers around the load in the latter so we can keep them completely out of the former and still enable wc.
Depends if you semantically then also are implicating its use for the ioremap_wc() area and if we've ensured we've visited all other possibilities to avoid this. Instead of replying here though it seems we have a large general ioremap() semantic discussion ongoing on another thread which is far ahead of this one and more generalized. Mind following up there, seems the party is there:
http://lkml.kernel.org/r/[email protected]
Luis