mtrr: avoid ifdef'ery with phys_wc_to_mtrr_index()
Subsystems (4)
PATCH v3 1/1 mtrr: avoid ifdef'ery with phys_wc_to_mtrr_index()
From: "Luis R. Rodriguez" <[email protected]>
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.
Cc Toshi Kani <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Will Deacon <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Abhilash Kesavan <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Cristian Stoica <[email protected]>
Cc dri-devel at lists.freedesktop.org
Cc Suresh Siddha <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Antonino Daplas <[email protected]>
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Tomi Valkeinen <[email protected]>
Cc Ville Syrj?l? <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Davidlohr Bueso <[email protected]>
Cc x86 at kernel.org
Cc linux-fbdev at vger.kernel.org
Cc linux-kernel at vger.kernel.org
Signed-off-by Luis R. Rodriguez <[email protected]>
--- arch/x86/include/asm/io.h | 3 +++ arch/x86/include/asm/mtrr.h | 5 ----- arch/x86/kernel/cpu/mtrr/main.c | 6 +++--- drivers/gpu/drm/drm_ioctl.c | 14 +------------- include/linux/io.h | 6 ++++++ 5 files changed, 13 insertions(+), 21 deletions(-)
arch/x86/include/asm/io.h +3 -0
@@ -339,6 +339,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,#define IO_SPACE_LIMIT 0xffff#ifdef CONFIG_MTRR +extern int __must_check arch_phys_wc_index (int handle); +#define arch_phys_wc_index arch_phys_wc_index +extern int __must_check arch_phys_wc_add (unsigned long base,unsigned long size);extern void arch_phys_wc_del (int handle);
arch/x86/include/asm/mtrr.h +0 -5
@@ -48,7 +48,6 @@ extern void mtrr_aps_init(void);extern void mtrr_bp_restore (void );extern int mtrr_trim_uncached_memory (unsigned long end_pfn);extern int amd_special_default_mtrr (void ); -extern int phys_wc_to_mtrr_index (int handle);# else static inline u8 mtrr_type_lookup (u64 addr,u64 end,u8 *uniform) {
@@ -85,10 +84,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)static inline void mtrr_centaur_report_mcr (int mcr,u32 lo,u32 hi) { } -static inline int phys_wc_to_mtrr_index (int handle) -{ -return -1 ; -}#define mtrr_ap_init () do {} while (0)#define mtrr_bp_init () do {} while (0)
arch/x86/kernel/cpu/mtrr/main.c +3 -3
@@ -580,7 +580,7 @@ void arch_phys_wc_del(int handle)EXPORT_SYMBOL (arch_phys_wc_del);/* -* phys_wc_to_mtrr_index - translates arch_phys_wc_add's return value +* arch_phys_wc_index - translates arch_phys_wc_add's return value * @handle: Return value from arch_phys_wc_add * * This will turn the return value from arch_phys_wc_add into an mtrr
@@ -590,14 +590,14 @@ EXPORT_SYMBOL(arch_phys_wc_del);* in printk line. Alas there is an illegitimate use in some ancient * drm ioctls. */ -int phys_wc_to_mtrr_index (int handle) +int arch_phys_wc_index (int handle) {if (handle <MTRR_TO_PHYS_WC_OFFSET )return -1 ;else return handle -MTRR_TO_PHYS_WC_OFFSET ; } -EXPORT_SYMBOL_GPL (phys_wc_to_mtrr_index); +EXPORT_SYMBOL_GPL (arch_phys_wc_index);/* * HACK ALERT!
drivers/gpu/drm/drm_ioctl.c +1 -13
@@ -36,9 +36,6 @@#include <linux/pci.h> #include <linux/export.h> -#ifdef CONFIG_X86 -#include <asm/mtrr.h> -#endif static int drm_version (struct drm_device *dev,void *data,struct drm_file *file_priv);
@@ -197,16 +194,7 @@ static int drm_getmap(struct drm_device *dev, void *data, map->type = r_list->map->type; map->flags = r_list->map->flags; map->handle = (void *)(unsigned long ) r_list->user_token; - -#ifdef CONFIG_X86 -/* -* There appears to be exactly one user of the mtrr index: dritest. -* It's easy enough to keep it working on non-PAT systems. -*/ - map->mtrr =phys_wc_to_mtrr_index (r_list->map->mtrr); -#else - map->mtrr =-1 ; -#endif + map->mtrr =arch_phys_wc_index (r_list->map->mtrr);mutex_unlock (&dev->struct_mutex);
include/linux/io.h +6 -0
@@ -111,6 +111,12 @@ static inline void arch_phys_wc_del(int handle) }#define arch_phys_wc_add arch_phys_wc_add +#ifndef arch_phys_wc_index +static inline int arch_phys_wc_index (int handle) +{ +return -1 ; +} +#define arch_phys_wc_index arch_phys_wc_index#endif #endif /* _LINUX_IO_H */
Signature · 1 line
2.3.2.209.gd67f9d5.dirty
Quoted 151 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
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.hfor access to helpers.Cc Toshi Kani <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Will Deacon <[email protected]>Cc Thierry Reding <[email protected]>Cc Andrew Morton <[email protected]>Cc Dave Hansen <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Catalin Marinas <[email protected]>Cc Abhilash Kesavan <[email protected]>Cc Matthias Brugger <[email protected]>Cc Cristian Stoica <[email protected]>Cc Suresh Siddha <[email protected]>Cc Linus Torvalds <[email protected]>Cc Juergen Gross <[email protected]>Cc Daniel Vetter <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Dave Airlie <[email protected]>Cc Antonino Daplas <[email protected]>Cc Jean-Christophe Plagniol-Villard <[email protected]>Cc Tomi Valkeinen <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Mel Gorman <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Borislav Petkov <[email protected]>Cc Davidlohr Bueso <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- arch/x86/include/asm/io.h | 3 +++ arch/x86/include/asm/mtrr.h | 5 ----- arch/x86/kernel/cpu/mtrr/main.c | 6 +++--- drivers/gpu/drm/drm_ioctl.c | 14 +------------- include/linux/io.h | 6 ++++++ 5 files changed, 13 insertions(+), 21 deletions(-)arch/x86/include/asm/io.h +3
-0@@ -339,6 +339,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,#define IO_SPACE_LIMIT 0xffff#ifdef CONFIG_MTRR +extern int __must_check arch_phys_wc_index (int handle); +#define arch_phys_wc_index arch_phys_wc_index +extern int __must_check arch_phys_wc_add (unsigned long base,unsigned long size);extern void arch_phys_wc_del (int handle);arch/x86/include/asm/mtrr.h +0
-5@@ -48,7 +48,6 @@ extern void mtrr_aps_init(void);extern void mtrr_bp_restore (void );extern int mtrr_trim_uncached_memory (unsigned long end_pfn);extern int amd_special_default_mtrr (void ); -extern int phys_wc_to_mtrr_index (int handle);# else static inline u8 mtrr_type_lookup (u64 addr,u64 end,u8 *uniform) {@@ -85,10 +84,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)static inline void mtrr_centaur_report_mcr (int mcr,u32 lo,u32 hi) { } -static inline int phys_wc_to_mtrr_index (int handle) -{ -return -1 ; -}#define mtrr_ap_init () do {} while (0)#define mtrr_bp_init () do {} while (0)arch/x86/kernel/cpu/mtrr/main.c +3
-3@@ -580,7 +580,7 @@ void arch_phys_wc_del(int handle)EXPORT_SYMBOL (arch_phys_wc_del);/* -* phys_wc_to_mtrr_index - translates arch_phys_wc_add's return value +* arch_phys_wc_index - translates arch_phys_wc_add's return value * @handle: Return value from arch_phys_wc_add * * This will turn the return value from arch_phys_wc_add into an mtrr @@ -590,14 +590,14 @@ EXPORT_SYMBOL(arch_phys_wc_del);* in printk line. Alas there is an illegitimate use in some ancient * drm ioctls. */ -int phys_wc_to_mtrr_index (int handle) +int arch_phys_wc_index (int handle) {if (handle <MTRR_TO_PHYS_WC_OFFSET )return -1 ;else return handle -MTRR_TO_PHYS_WC_OFFSET ; } -EXPORT_SYMBOL_GPL (phys_wc_to_mtrr_index); +EXPORT_SYMBOL_GPL (arch_phys_wc_index);/* * HACK ALERT! drivers/gpu/drm/drm_ioctl.c +1
-13@@ -36,9 +36,6 @@#include <linux/pci.h> #include <linux/export.h> -#ifdef CONFIG_X86 -#include <asm/mtrr.h> -#endif static int drm_version (struct drm_device *dev,void *data,struct drm_file *file_priv);@@ -197,16 +194,7 @@ static int drm_getmap(struct drm_device *dev, void *data, map->type = r_list->map->type; map->flags = r_list->map->flags; map->handle = (void *)(unsigned long ) r_list->user_token; - -#ifdef CONFIG_X86 -/* -* There appears to be exactly one user of the mtrr index: dritest. -* It's easy enough to keep it working on non-PAT systems. -*/ - map->mtrr =phys_wc_to_mtrr_index (r_list->map->mtrr); -#else - map->mtrr =-1 ; -#endif + map->mtrr =arch_phys_wc_index (r_list->map->mtrr);mutex_unlock (&dev->struct_mutex);include/linux/io.h +0
-0
include/linux/io.h static inline void arch_phys_wc_del(int handle) · line 120
Quoted 10 lines
include/linux/io.h +6
-0@@ -111,6 +111,12 @@ static inline void arch_phys_wc_del(int handle) }#define arch_phys_wc_add arch_phys_wc_add +#ifndef arch_phys_wc_index +static inline int arch_phys_wc_index (int handle) +{ +return -1 ; +} +#define arch_phys_wc_index arch_phys_wc_index#endif
Sorry this is missing an #endif here, will send a v4.
Luis