[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 03/11] drivers/video/fbdev/kyrofb: Use arch_phys_wc_add() and pci_ioremap_wc_bar()



From: "Luis R. Rodriguez" <mcgrof@xxxxxxxx>

Convert the driver from using the x86-specific MTRR code to the
architecture-agnostic arch_phys_wc_add(). It will avoid MTRR if
write-combining is available, in order to take advantage of that
also ensure the ioremapped 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 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@xxxxxxxx>
Acked-by: Tomi Valkeinen <tomi.valkeinen@xxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
Cc: Antonino Daplas <adaplas@xxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: benh@xxxxxxxxxxxxxxxxxxx
Cc: bhelgaas@xxxxxxxxxx
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
Cc: Dave Airlie <airlied@xxxxxxxxxx>
Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@xxxxxxxxxxxx>
Cc: Jingoo Han <jg1.han@xxxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Cc: linux-fbdev@xxxxxxxxxxxxxxx
Cc: linux-pci@xxxxxxxxxxxxxxx
Cc: mst@xxxxxxxxxx
Cc: Suresh Siddha <sbsiddha@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: toshi.kani@xxxxxx
Link: 
http://lkml.kernel.org/r/1435195342-26879-4-git-send-email-mcgrof@xxxxxxxxxxxxxxxx
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
---
 drivers/video/fbdev/kyro/fbdev.c | 33 +++++++++++----------------------
 include/video/kyro.h             |  4 +---
 2 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 65041e15fd59..5bb01533271e 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -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);
diff --git a/include/video/kyro.h b/include/video/kyro.h
index c563968e926c..b958c2e9c915 100644
--- a/include/video/kyro.h
+++ b/include/video/kyro.h
@@ -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);
-- 
2.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.