Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mm/mtrr: Avoid #ifdeffery with phys_wc_to_mtrr_index()

There is only one user but since we're going to bury MTRR next
out of access to drivers, expose this last piece of API to
drivers in a general fashion only needing io.h for access to
helpers.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Abhilash Kesavan <a.kesavan@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Cristian Stoica <cristian.stoica@freescale.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will.deacon@arm.com>
Cc: dri-devel@lists.freedesktop.org
Link: http://lkml.kernel.org/r/1429722736-4473-1-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-11-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Luis R. Rodriguez and committed by
Ingo Molnar
7d010fdf 2f9e8973

+14 -21
+3
arch/x86/include/asm/io.h
··· 339 339 #define IO_SPACE_LIMIT 0xffff 340 340 341 341 #ifdef CONFIG_MTRR 342 + extern int __must_check arch_phys_wc_index(int handle); 343 + #define arch_phys_wc_index arch_phys_wc_index 344 + 342 345 extern int __must_check arch_phys_wc_add(unsigned long base, 343 346 unsigned long size); 344 347 extern void arch_phys_wc_del(int handle);
-5
arch/x86/include/asm/mtrr.h
··· 48 48 extern void mtrr_bp_restore(void); 49 49 extern int mtrr_trim_uncached_memory(unsigned long end_pfn); 50 50 extern int amd_special_default_mtrr(void); 51 - extern int phys_wc_to_mtrr_index(int handle); 52 51 # else 53 52 static inline u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform) 54 53 { ··· 82 83 } 83 84 static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) 84 85 { 85 - } 86 - static inline int phys_wc_to_mtrr_index(int handle) 87 - { 88 - return -1; 89 86 } 90 87 91 88 #define mtrr_ap_init() do {} while (0)
+3 -3
arch/x86/kernel/cpu/mtrr/main.c
··· 580 580 EXPORT_SYMBOL(arch_phys_wc_del); 581 581 582 582 /* 583 - * phys_wc_to_mtrr_index - translates arch_phys_wc_add's return value 583 + * arch_phys_wc_index - translates arch_phys_wc_add's return value 584 584 * @handle: Return value from arch_phys_wc_add 585 585 * 586 586 * This will turn the return value from arch_phys_wc_add into an mtrr ··· 590 590 * in printk line. Alas there is an illegitimate use in some ancient 591 591 * drm ioctls. 592 592 */ 593 - int phys_wc_to_mtrr_index(int handle) 593 + int arch_phys_wc_index(int handle) 594 594 { 595 595 if (handle < MTRR_TO_PHYS_WC_OFFSET) 596 596 return -1; 597 597 else 598 598 return handle - MTRR_TO_PHYS_WC_OFFSET; 599 599 } 600 - EXPORT_SYMBOL_GPL(phys_wc_to_mtrr_index); 600 + EXPORT_SYMBOL_GPL(arch_phys_wc_index); 601 601 602 602 /* 603 603 * HACK ALERT!
+1 -13
drivers/gpu/drm/drm_ioctl.c
··· 36 36 37 37 #include <linux/pci.h> 38 38 #include <linux/export.h> 39 - #ifdef CONFIG_X86 40 - #include <asm/mtrr.h> 41 - #endif 42 39 43 40 static int drm_version(struct drm_device *dev, void *data, 44 41 struct drm_file *file_priv); ··· 194 197 map->type = r_list->map->type; 195 198 map->flags = r_list->map->flags; 196 199 map->handle = (void *)(unsigned long) r_list->user_token; 197 - 198 - #ifdef CONFIG_X86 199 - /* 200 - * There appears to be exactly one user of the mtrr index: dritest. 201 - * It's easy enough to keep it working on non-PAT systems. 202 - */ 203 - map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr); 204 - #else 205 - map->mtrr = -1; 206 - #endif 200 + map->mtrr = arch_phys_wc_index(r_list->map->mtrr); 207 201 208 202 mutex_unlock(&dev->struct_mutex); 209 203
+7
include/linux/io.h
··· 111 111 } 112 112 113 113 #define arch_phys_wc_add arch_phys_wc_add 114 + #ifndef arch_phys_wc_index 115 + static inline int arch_phys_wc_index(int handle) 116 + { 117 + return -1; 118 + } 119 + #define arch_phys_wc_index arch_phys_wc_index 120 + #endif 114 121 #endif 115 122 116 123 #endif /* _LINUX_IO_H */