drivers/video/fbdev/s3fb: Use arch_phys_wc_add() and pci_iomap_wc()
drivers/video/fbdev/s3fb: Use arch_phys_wc_add() and pci_iomap_wc()

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(). It will avoid MTRRs 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 <d4fa18192c5a479e564d29c2300c2e15afd1d8d7@suse.com>
Signed-off-by: Borislav Petkov <0691a664b24b6f15b20cd5aee64b72271db08be1@suse.de>
Acked-by: Tomi Valkeinen <e1ca4dbb8be1acaf20734fecd2da10ed1d46a9bb@ti.com>
Cc: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Cc: Andy Lutomirski <2cc0d0d76de2e6f37b92deeb83c85cb306fc5dc1@amacapital.net>
Cc: Antonino Daplas <be03a811842969f6b435f66cb85a30eb479a8702@gmail.com>
Cc: Arnd Bergmann <f2c659f01951776204a6c5b902787d9019fbeebd@arndb.de>
Cc: Daniel Vetter <c1b6782c4af8f0673da8923a0702a1832e5940f4@ffwll.ch>
Cc: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>
Cc: Geert Uytterhoeven <0da414d9d963da4039c2a0525b1844228075aa58@linux-m68k.org>
Cc: H. Peter Anvin <8a453bad9912ffe59bc0f0b8abe03df9be19379e@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <9fc55922e47e21cb004bb878f69efa10ab51cf02@jcrosoft.com>
Cc: Jingoo Han <fc379137a64feb86ce38ec5811a14280acc1ccfc@samsung.com>
Cc: Juergen Gross <29bbaec13092d36559e3abc6f27f7d09c395819f@suse.com>
Cc: Lad, Prabhakar <b468bd3711e6074f1f3ca387583c4bfe5a29e9a6@gmail.com>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Rickard Strandqvist <b2870f70e324b62b54eced4cf50284b23ec5baab@spectrumdigital.se>
Cc: Suresh Siddha <f1717d7a737dbd1ee265018492337a4bb54fe08a@gmail.com>
Cc: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Cc: f2295d84e358395675bc8031be58672073ae065e@linux.ie
Cc: a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org
Cc: f10ec01be0c6b54271af5c550cd257810bdf3268@google.com
Cc: 24ee2bf0bd8ac766c348bf1f0639943bac1535c6@intel.com
Cc: da3a51b335cef0eb0e2c329c5ef6bcd6acef687a@oracle.com
Cc: 884c56c11fd64773fc86cd52a4ea5cbef674401a@vger.kernel.org
Cc: c6ec3e7b985c17ad0107cdbe9b999c23f1042f60@vger.kernel.org
Cc: 255103e50249e3d658441816e0597170ebfc16ef@redhat.com
Cc: 322b9f75d3806917607539efc168804d71b9503d@hp.com
Cc: 5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com
Cc: 196a79ea1bad81d8c954adf793448b0a45442f28@lists.xensource.com
Link: d44651e3fd125cf6607081df4090e18293214de3@do-not-panic.com
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

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