staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()

The same area used for ioremap() is used for the MTRR area.
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: Arnaud Patard <792745173c1ee81f4d7d786155d4c148b6e57204@rtp-net.org>
Cc: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>
Cc: Aaro Koskinen <13423a3f3006b5859cfceae66d59451f5eb4e205@iki.fi>
Cc: Brian Vandre <45f0a450d39eca7f47d026a9882dee14d5d0520d@gmail.com>
Cc: Thomas Gummerer <b5d5468c18b856edee6cf44fd3ea820cd261b068@gmail.com>
Cc: Aya Mahfouz <5af60d88056a2c6dcdb35595ae7d607e25785d55@gmail.com>
Cc: Lubomir Rintel <c9b9bbc6e9b0bc7e9cec5af1551c7b98adb9530c@v3.sk>
Cc: Vitor Braga <212629f0e5596743fbce4279618d79dd155e5792@gmail.com>
Cc: Sudip Mukherjee <551ae05ce198473af5b9da594240f54df5f81e31@gmail.com>
Cc: Suresh Siddha <f1717d7a737dbd1ee265018492337a4bb54fe08a@gmail.com>
Cc: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>
Cc: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Cc: Juergen Gross <29bbaec13092d36559e3abc6f27f7d09c395819f@suse.com>
Cc: Daniel Vetter <c1b6782c4af8f0673da8923a0702a1832e5940f4@ffwll.ch>
Cc: Andy Lutomirski <2cc0d0d76de2e6f37b92deeb83c85cb306fc5dc1@amacapital.net>
Cc: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>
Cc: Antonino Daplas <be03a811842969f6b435f66cb85a30eb479a8702@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <9fc55922e47e21cb004bb878f69efa10ab51cf02@jcrosoft.com>
Cc: Tomi Valkeinen <e1ca4dbb8be1acaf20734fecd2da10ed1d46a9bb@ti.com>
Cc: 21a6cafaf0e9b0080692d699c1538d0dfa42b47a@driverdev.osuosl.org
Cc: 884c56c11fd64773fc86cd52a4ea5cbef674401a@vger.kernel.org
Cc: 2578944098299abf708b08eff6fcf60565553586@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <d4fa18192c5a479e564d29c2300c2e15afd1d8d7@suse.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs