aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug161
-rw-r--r--lib/debugobjects.c141
-rw-r--r--lib/dma-direct.c35
-rw-r--r--lib/raid6/Makefile6
-rw-r--r--lib/raid6/algos.c3
-rw-r--r--lib/raid6/test/Makefile7
-rw-r--r--lib/raid6/tilegx.uc87
-rw-r--r--lib/swiotlb.c77
-rw-r--r--lib/test_user_copy.c3
9 files changed, 224 insertions, 296 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 64155e310a9f..00eeff94b357 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -165,7 +165,7 @@ config DEBUG_INFO_REDUCED
165 165
166config DEBUG_INFO_SPLIT 166config DEBUG_INFO_SPLIT
167 bool "Produce split debuginfo in .dwo files" 167 bool "Produce split debuginfo in .dwo files"
168 depends on DEBUG_INFO && !FRV 168 depends on DEBUG_INFO
169 help 169 help
170 Generate debug info into separate .dwo files. This significantly 170 Generate debug info into separate .dwo files. This significantly
171 reduces the build directory size for builds with DEBUG_INFO, 171 reduces the build directory size for builds with DEBUG_INFO,
@@ -354,10 +354,7 @@ config ARCH_WANT_FRAME_POINTERS
354 354
355config FRAME_POINTER 355config FRAME_POINTER
356 bool "Compile the kernel with frame pointers" 356 bool "Compile the kernel with frame pointers"
357 depends on DEBUG_KERNEL && \ 357 depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
358 (CRIS || M68K || FRV || UML || \
359 SUPERH || BLACKFIN || MN10300 || METAG) || \
360 ARCH_WANT_FRAME_POINTERS
361 default y if (DEBUG_INFO && UML) || ARCH_WANT_FRAME_POINTERS 358 default y if (DEBUG_INFO && UML) || ARCH_WANT_FRAME_POINTERS
362 help 359 help
363 If you say Y here the resulting kernel image will be slightly 360 If you say Y here the resulting kernel image will be slightly
@@ -1034,69 +1031,20 @@ config DEBUG_PREEMPT
1034 1031
1035menu "Lock Debugging (spinlocks, mutexes, etc...)" 1032menu "Lock Debugging (spinlocks, mutexes, etc...)"
1036 1033
1037config DEBUG_RT_MUTEXES 1034config LOCK_DEBUGGING_SUPPORT
1038 bool "RT Mutex debugging, deadlock detection" 1035 bool
1039 depends on DEBUG_KERNEL && RT_MUTEXES 1036 depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1040 help 1037 default y
1041 This allows rt mutex semantics violations and rt mutex related
1042 deadlocks (lockups) to be detected and reported automatically.
1043
1044config DEBUG_SPINLOCK
1045 bool "Spinlock and rw-lock debugging: basic checks"
1046 depends on DEBUG_KERNEL
1047 select UNINLINE_SPIN_UNLOCK
1048 help
1049 Say Y here and build SMP to catch missing spinlock initialization
1050 and certain other kinds of spinlock errors commonly made. This is
1051 best used in conjunction with the NMI watchdog so that spinlock
1052 deadlocks are also debuggable.
1053
1054config DEBUG_MUTEXES
1055 bool "Mutex debugging: basic checks"
1056 depends on DEBUG_KERNEL
1057 help
1058 This feature allows mutex semantics violations to be detected and
1059 reported.
1060
1061config DEBUG_WW_MUTEX_SLOWPATH
1062 bool "Wait/wound mutex debugging: Slowpath testing"
1063 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1064 select DEBUG_LOCK_ALLOC
1065 select DEBUG_SPINLOCK
1066 select DEBUG_MUTEXES
1067 help
1068 This feature enables slowpath testing for w/w mutex users by
1069 injecting additional -EDEADLK wound/backoff cases. Together with
1070 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
1071 will test all possible w/w mutex interface abuse with the
1072 exception of simply not acquiring all the required locks.
1073 Note that this feature can introduce significant overhead, so
1074 it really should not be enabled in a production or distro kernel,
1075 even a debug kernel. If you are a driver writer, enable it. If
1076 you are a distro, do not.
1077
1078config DEBUG_LOCK_ALLOC
1079 bool "Lock debugging: detect incorrect freeing of live locks"
1080 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1081 select DEBUG_SPINLOCK
1082 select DEBUG_MUTEXES
1083 select DEBUG_RT_MUTEXES if RT_MUTEXES
1084 select LOCKDEP
1085 help
1086 This feature will check whether any held lock (spinlock, rwlock,
1087 mutex or rwsem) is incorrectly freed by the kernel, via any of the
1088 memory-freeing routines (kfree(), kmem_cache_free(), free_pages(),
1089 vfree(), etc.), whether a live lock is incorrectly reinitialized via
1090 spin_lock_init()/mutex_init()/etc., or whether there is any lock
1091 held during task exit.
1092 1038
1093config PROVE_LOCKING 1039config PROVE_LOCKING
1094 bool "Lock debugging: prove locking correctness" 1040 bool "Lock debugging: prove locking correctness"
1095 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 1041 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1096 select LOCKDEP 1042 select LOCKDEP
1097 select DEBUG_SPINLOCK 1043 select DEBUG_SPINLOCK
1098 select DEBUG_MUTEXES 1044 select DEBUG_MUTEXES
1099 select DEBUG_RT_MUTEXES if RT_MUTEXES 1045 select DEBUG_RT_MUTEXES if RT_MUTEXES
1046 select DEBUG_RWSEMS if RWSEM_SPIN_ON_OWNER
1047 select DEBUG_WW_MUTEX_SLOWPATH
1100 select DEBUG_LOCK_ALLOC 1048 select DEBUG_LOCK_ALLOC
1101 select TRACE_IRQFLAGS 1049 select TRACE_IRQFLAGS
1102 default n 1050 default n
@@ -1134,20 +1082,9 @@ config PROVE_LOCKING
1134 1082
1135 For more details, see Documentation/locking/lockdep-design.txt. 1083 For more details, see Documentation/locking/lockdep-design.txt.
1136 1084
1137config LOCKDEP
1138 bool
1139 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1140 select STACKTRACE
1141 select FRAME_POINTER if !MIPS && !PPC && !ARM_UNWIND && !S390 && !MICROBLAZE && !ARC && !SCORE && !X86
1142 select KALLSYMS
1143 select KALLSYMS_ALL
1144
1145config LOCKDEP_SMALL
1146 bool
1147
1148config LOCK_STAT 1085config LOCK_STAT
1149 bool "Lock usage statistics" 1086 bool "Lock usage statistics"
1150 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 1087 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1151 select LOCKDEP 1088 select LOCKDEP
1152 select DEBUG_SPINLOCK 1089 select DEBUG_SPINLOCK
1153 select DEBUG_MUTEXES 1090 select DEBUG_MUTEXES
@@ -1167,6 +1104,80 @@ config LOCK_STAT
1167 CONFIG_LOCK_STAT defines "contended" and "acquired" lock events. 1104 CONFIG_LOCK_STAT defines "contended" and "acquired" lock events.
1168 (CONFIG_LOCKDEP defines "acquire" and "release" events.) 1105 (CONFIG_LOCKDEP defines "acquire" and "release" events.)
1169 1106
1107config DEBUG_RT_MUTEXES
1108 bool "RT Mutex debugging, deadlock detection"
1109 depends on DEBUG_KERNEL && RT_MUTEXES
1110 help
1111 This allows rt mutex semantics violations and rt mutex related
1112 deadlocks (lockups) to be detected and reported automatically.
1113
1114config DEBUG_SPINLOCK
1115 bool "Spinlock and rw-lock debugging: basic checks"
1116 depends on DEBUG_KERNEL
1117 select UNINLINE_SPIN_UNLOCK
1118 help
1119 Say Y here and build SMP to catch missing spinlock initialization
1120 and certain other kinds of spinlock errors commonly made. This is
1121 best used in conjunction with the NMI watchdog so that spinlock
1122 deadlocks are also debuggable.
1123
1124config DEBUG_MUTEXES
1125 bool "Mutex debugging: basic checks"
1126 depends on DEBUG_KERNEL
1127 help
1128 This feature allows mutex semantics violations to be detected and
1129 reported.
1130
1131config DEBUG_WW_MUTEX_SLOWPATH
1132 bool "Wait/wound mutex debugging: Slowpath testing"
1133 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1134 select DEBUG_LOCK_ALLOC
1135 select DEBUG_SPINLOCK
1136 select DEBUG_MUTEXES
1137 help
1138 This feature enables slowpath testing for w/w mutex users by
1139 injecting additional -EDEADLK wound/backoff cases. Together with
1140 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
1141 will test all possible w/w mutex interface abuse with the
1142 exception of simply not acquiring all the required locks.
1143 Note that this feature can introduce significant overhead, so
1144 it really should not be enabled in a production or distro kernel,
1145 even a debug kernel. If you are a driver writer, enable it. If
1146 you are a distro, do not.
1147
1148config DEBUG_RWSEMS
1149 bool "RW Semaphore debugging: basic checks"
1150 depends on DEBUG_KERNEL && RWSEM_SPIN_ON_OWNER
1151 help
1152 This debugging feature allows mismatched rw semaphore locks and unlocks
1153 to be detected and reported.
1154
1155config DEBUG_LOCK_ALLOC
1156 bool "Lock debugging: detect incorrect freeing of live locks"
1157 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1158 select DEBUG_SPINLOCK
1159 select DEBUG_MUTEXES
1160 select DEBUG_RT_MUTEXES if RT_MUTEXES
1161 select LOCKDEP
1162 help
1163 This feature will check whether any held lock (spinlock, rwlock,
1164 mutex or rwsem) is incorrectly freed by the kernel, via any of the
1165 memory-freeing routines (kfree(), kmem_cache_free(), free_pages(),
1166 vfree(), etc.), whether a live lock is incorrectly reinitialized via
1167 spin_lock_init()/mutex_init()/etc., or whether there is any lock
1168 held during task exit.
1169
1170config LOCKDEP
1171 bool
1172 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1173 select STACKTRACE
1174 select FRAME_POINTER if !MIPS && !PPC && !ARM_UNWIND && !S390 && !MICROBLAZE && !ARC && !X86
1175 select KALLSYMS
1176 select KALLSYMS_ALL
1177
1178config LOCKDEP_SMALL
1179 bool
1180
1170config DEBUG_LOCKDEP 1181config DEBUG_LOCKDEP
1171 bool "Lock dependency engine debugging" 1182 bool "Lock dependency engine debugging"
1172 depends on DEBUG_KERNEL && LOCKDEP 1183 depends on DEBUG_KERNEL && LOCKDEP
@@ -1571,7 +1582,7 @@ config FAULT_INJECTION_STACKTRACE_FILTER
1571 depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT 1582 depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
1572 depends on !X86_64 1583 depends on !X86_64
1573 select STACKTRACE 1584 select STACKTRACE
1574 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC && !SCORE && !X86 1585 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC && !X86
1575 help 1586 help
1576 Provide stacktrace filter for fault-injection capabilities 1587 Provide stacktrace filter for fault-injection capabilities
1577 1588
@@ -1969,7 +1980,7 @@ config STRICT_DEVMEM
1969 bool "Filter access to /dev/mem" 1980 bool "Filter access to /dev/mem"
1970 depends on MMU && DEVMEM 1981 depends on MMU && DEVMEM
1971 depends on ARCH_HAS_DEVMEM_IS_ALLOWED 1982 depends on ARCH_HAS_DEVMEM_IS_ALLOWED
1972 default y if TILE || PPC || X86 || ARM64 1983 default y if PPC || X86 || ARM64
1973 ---help--- 1984 ---help---
1974 If this option is disabled, you allow userspace (root) access to all 1985 If this option is disabled, you allow userspace (root) access to all
1975 of memory, including kernel and userspace memory. Accidental 1986 of memory, including kernel and userspace memory. Accidental
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 2f5349c6e81a..994be4805cec 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -42,14 +42,18 @@ static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
42static DEFINE_RAW_SPINLOCK(pool_lock); 42static DEFINE_RAW_SPINLOCK(pool_lock);
43 43
44static HLIST_HEAD(obj_pool); 44static HLIST_HEAD(obj_pool);
45static HLIST_HEAD(obj_to_free);
45 46
46static int obj_pool_min_free = ODEBUG_POOL_SIZE; 47static int obj_pool_min_free = ODEBUG_POOL_SIZE;
47static int obj_pool_free = ODEBUG_POOL_SIZE; 48static int obj_pool_free = ODEBUG_POOL_SIZE;
48static int obj_pool_used; 49static int obj_pool_used;
49static int obj_pool_max_used; 50static int obj_pool_max_used;
51/* The number of objs on the global free list */
52static int obj_nr_tofree;
50static struct kmem_cache *obj_cache; 53static struct kmem_cache *obj_cache;
51 54
52static int debug_objects_maxchain __read_mostly; 55static int debug_objects_maxchain __read_mostly;
56static int __maybe_unused debug_objects_maxchecked __read_mostly;
53static int debug_objects_fixups __read_mostly; 57static int debug_objects_fixups __read_mostly;
54static int debug_objects_warnings __read_mostly; 58static int debug_objects_warnings __read_mostly;
55static int debug_objects_enabled __read_mostly 59static int debug_objects_enabled __read_mostly
@@ -96,12 +100,32 @@ static const char *obj_states[ODEBUG_STATE_MAX] = {
96static void fill_pool(void) 100static void fill_pool(void)
97{ 101{
98 gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN; 102 gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
99 struct debug_obj *new; 103 struct debug_obj *new, *obj;
100 unsigned long flags; 104 unsigned long flags;
101 105
102 if (likely(obj_pool_free >= debug_objects_pool_min_level)) 106 if (likely(obj_pool_free >= debug_objects_pool_min_level))
103 return; 107 return;
104 108
109 /*
110 * Reuse objs from the global free list; they will be reinitialized
111 * when allocating.
112 */
113 while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
114 raw_spin_lock_irqsave(&pool_lock, flags);
115 /*
116 * Recheck with the lock held as the worker thread might have
117 * won the race and freed the global free list already.
118 */
119 if (obj_nr_tofree) {
120 obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
121 hlist_del(&obj->node);
122 obj_nr_tofree--;
123 hlist_add_head(&obj->node, &obj_pool);
124 obj_pool_free++;
125 }
126 raw_spin_unlock_irqrestore(&pool_lock, flags);
127 }
128
105 if (unlikely(!obj_cache)) 129 if (unlikely(!obj_cache))
106 return; 130 return;
107 131
@@ -177,62 +201,76 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
177 * workqueue function to free objects. 201 * workqueue function to free objects.
178 * 202 *
179 * To reduce contention on the global pool_lock, the actual freeing of 203 * To reduce contention on the global pool_lock, the actual freeing of
180 * debug objects will be delayed if the pool_lock is busy. We also free 204 * debug objects will be delayed if the pool_lock is busy.
181 * the objects in a batch of 4 for each lock/unlock cycle.
182 */ 205 */
183#define ODEBUG_FREE_BATCH 4
184
185static void free_obj_work(struct work_struct *work) 206static void free_obj_work(struct work_struct *work)
186{ 207{
187 struct debug_obj *objs[ODEBUG_FREE_BATCH]; 208 struct hlist_node *tmp;
209 struct debug_obj *obj;
188 unsigned long flags; 210 unsigned long flags;
189 int i; 211 HLIST_HEAD(tofree);
190 212
191 if (!raw_spin_trylock_irqsave(&pool_lock, flags)) 213 if (!raw_spin_trylock_irqsave(&pool_lock, flags))
192 return; 214 return;
193 while (obj_pool_free >= debug_objects_pool_size + ODEBUG_FREE_BATCH) {
194 for (i = 0; i < ODEBUG_FREE_BATCH; i++) {
195 objs[i] = hlist_entry(obj_pool.first,
196 typeof(*objs[0]), node);
197 hlist_del(&objs[i]->node);
198 }
199 215
200 obj_pool_free -= ODEBUG_FREE_BATCH; 216 /*
201 debug_objects_freed += ODEBUG_FREE_BATCH; 217 * The objs on the pool list might be allocated before the work is
202 /* 218 * run, so recheck if pool list it full or not, if not fill pool
203 * We release pool_lock across kmem_cache_free() to 219 * list from the global free list
204 * avoid contention on pool_lock. 220 */
205 */ 221 while (obj_nr_tofree && obj_pool_free < debug_objects_pool_size) {
206 raw_spin_unlock_irqrestore(&pool_lock, flags); 222 obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
207 for (i = 0; i < ODEBUG_FREE_BATCH; i++) 223 hlist_del(&obj->node);
208 kmem_cache_free(obj_cache, objs[i]); 224 hlist_add_head(&obj->node, &obj_pool);
209 if (!raw_spin_trylock_irqsave(&pool_lock, flags)) 225 obj_pool_free++;
210 return; 226 obj_nr_tofree--;
227 }
228
229 /*
230 * Pool list is already full and there are still objs on the free
231 * list. Move remaining free objs to a temporary list to free the
232 * memory outside the pool_lock held region.
233 */
234 if (obj_nr_tofree) {
235 hlist_move_list(&obj_to_free, &tofree);
236 debug_objects_freed += obj_nr_tofree;
237 obj_nr_tofree = 0;
211 } 238 }
212 raw_spin_unlock_irqrestore(&pool_lock, flags); 239 raw_spin_unlock_irqrestore(&pool_lock, flags);
240
241 hlist_for_each_entry_safe(obj, tmp, &tofree, node) {
242 hlist_del(&obj->node);
243 kmem_cache_free(obj_cache, obj);
244 }
213} 245}
214 246
215/* 247static bool __free_object(struct debug_obj *obj)
216 * Put the object back into the pool and schedule work to free objects
217 * if necessary.
218 */
219static void free_object(struct debug_obj *obj)
220{ 248{
221 unsigned long flags; 249 unsigned long flags;
222 int sched = 0; 250 bool work;
223 251
224 raw_spin_lock_irqsave(&pool_lock, flags); 252 raw_spin_lock_irqsave(&pool_lock, flags);
225 /* 253 work = (obj_pool_free > debug_objects_pool_size) && obj_cache;
226 * schedule work when the pool is filled and the cache is
227 * initialized:
228 */
229 if (obj_pool_free > debug_objects_pool_size && obj_cache)
230 sched = 1;
231 hlist_add_head(&obj->node, &obj_pool);
232 obj_pool_free++;
233 obj_pool_used--; 254 obj_pool_used--;
255
256 if (work) {
257 obj_nr_tofree++;
258 hlist_add_head(&obj->node, &obj_to_free);
259 } else {
260 obj_pool_free++;
261 hlist_add_head(&obj->node, &obj_pool);
262 }
234 raw_spin_unlock_irqrestore(&pool_lock, flags); 263 raw_spin_unlock_irqrestore(&pool_lock, flags);
235 if (sched) 264 return work;
265}
266
267/*
268 * Put the object back into the pool and schedule work to free objects
269 * if necessary.
270 */
271static void free_object(struct debug_obj *obj)
272{
273 if (__free_object(obj))
236 schedule_work(&debug_obj_work); 274 schedule_work(&debug_obj_work);
237} 275}
238 276
@@ -714,13 +752,13 @@ EXPORT_SYMBOL_GPL(debug_object_active_state);
714static void __debug_check_no_obj_freed(const void *address, unsigned long size) 752static void __debug_check_no_obj_freed(const void *address, unsigned long size)
715{ 753{
716 unsigned long flags, oaddr, saddr, eaddr, paddr, chunks; 754 unsigned long flags, oaddr, saddr, eaddr, paddr, chunks;
717 struct hlist_node *tmp;
718 HLIST_HEAD(freelist);
719 struct debug_obj_descr *descr; 755 struct debug_obj_descr *descr;
720 enum debug_obj_state state; 756 enum debug_obj_state state;
721 struct debug_bucket *db; 757 struct debug_bucket *db;
758 struct hlist_node *tmp;
722 struct debug_obj *obj; 759 struct debug_obj *obj;
723 int cnt; 760 int cnt, objs_checked = 0;
761 bool work = false;
724 762
725 saddr = (unsigned long) address; 763 saddr = (unsigned long) address;
726 eaddr = saddr + size; 764 eaddr = saddr + size;
@@ -751,21 +789,24 @@ repeat:
751 goto repeat; 789 goto repeat;
752 default: 790 default:
753 hlist_del(&obj->node); 791 hlist_del(&obj->node);
754 hlist_add_head(&obj->node, &freelist); 792 work |= __free_object(obj);
755 break; 793 break;
756 } 794 }
757 } 795 }
758 raw_spin_unlock_irqrestore(&db->lock, flags); 796 raw_spin_unlock_irqrestore(&db->lock, flags);
759 797
760 /* Now free them */
761 hlist_for_each_entry_safe(obj, tmp, &freelist, node) {
762 hlist_del(&obj->node);
763 free_object(obj);
764 }
765
766 if (cnt > debug_objects_maxchain) 798 if (cnt > debug_objects_maxchain)
767 debug_objects_maxchain = cnt; 799 debug_objects_maxchain = cnt;
800
801 objs_checked += cnt;
768 } 802 }
803
804 if (objs_checked > debug_objects_maxchecked)
805 debug_objects_maxchecked = objs_checked;
806
807 /* Schedule work to actually kmem_cache_free() objects */
808 if (work)
809 schedule_work(&debug_obj_work);
769} 810}
770 811
771void debug_check_no_obj_freed(const void *address, unsigned long size) 812void debug_check_no_obj_freed(const void *address, unsigned long size)
@@ -780,12 +821,14 @@ void debug_check_no_obj_freed(const void *address, unsigned long size)
780static int debug_stats_show(struct seq_file *m, void *v) 821static int debug_stats_show(struct seq_file *m, void *v)
781{ 822{
782 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain); 823 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain);
824 seq_printf(m, "max_checked :%d\n", debug_objects_maxchecked);
783 seq_printf(m, "warnings :%d\n", debug_objects_warnings); 825 seq_printf(m, "warnings :%d\n", debug_objects_warnings);
784 seq_printf(m, "fixups :%d\n", debug_objects_fixups); 826 seq_printf(m, "fixups :%d\n", debug_objects_fixups);
785 seq_printf(m, "pool_free :%d\n", obj_pool_free); 827 seq_printf(m, "pool_free :%d\n", obj_pool_free);
786 seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free); 828 seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free);
787 seq_printf(m, "pool_used :%d\n", obj_pool_used); 829 seq_printf(m, "pool_used :%d\n", obj_pool_used);
788 seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used); 830 seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used);
831 seq_printf(m, "on_free_list :%d\n", obj_nr_tofree);
789 seq_printf(m, "objs_allocated:%d\n", debug_objects_allocated); 832 seq_printf(m, "objs_allocated:%d\n", debug_objects_allocated);
790 seq_printf(m, "objs_freed :%d\n", debug_objects_freed); 833 seq_printf(m, "objs_freed :%d\n", debug_objects_freed);
791 return 0; 834 return 0;
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index c9e8e21cb334..c0bba30fef0a 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -9,6 +9,7 @@
9#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
10#include <linux/dma-contiguous.h> 10#include <linux/dma-contiguous.h>
11#include <linux/pfn.h> 11#include <linux/pfn.h>
12#include <linux/set_memory.h>
12 13
13#define DIRECT_MAPPING_ERROR 0 14#define DIRECT_MAPPING_ERROR 0
14 15
@@ -20,6 +21,14 @@
20#define ARCH_ZONE_DMA_BITS 24 21#define ARCH_ZONE_DMA_BITS 24
21#endif 22#endif
22 23
24/*
25 * For AMD SEV all DMA must be to unencrypted addresses.
26 */
27static inline bool force_dma_unencrypted(void)
28{
29 return sev_active();
30}
31
23static bool 32static bool
24check_addr(struct device *dev, dma_addr_t dma_addr, size_t size, 33check_addr(struct device *dev, dma_addr_t dma_addr, size_t size,
25 const char *caller) 34 const char *caller)
@@ -37,7 +46,9 @@ check_addr(struct device *dev, dma_addr_t dma_addr, size_t size,
37 46
38static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size) 47static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
39{ 48{
40 return phys_to_dma(dev, phys) + size - 1 <= dev->coherent_dma_mask; 49 dma_addr_t addr = force_dma_unencrypted() ?
50 __phys_to_dma(dev, phys) : phys_to_dma(dev, phys);
51 return addr + size - 1 <= dev->coherent_dma_mask;
41} 52}
42 53
43void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, 54void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
@@ -46,6 +57,10 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
46 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; 57 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
47 int page_order = get_order(size); 58 int page_order = get_order(size);
48 struct page *page = NULL; 59 struct page *page = NULL;
60 void *ret;
61
62 /* we always manually zero the memory once we are done: */
63 gfp &= ~__GFP_ZERO;
49 64
50 /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */ 65 /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
51 if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)) 66 if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
@@ -78,10 +93,15 @@ again:
78 93
79 if (!page) 94 if (!page)
80 return NULL; 95 return NULL;
81 96 ret = page_address(page);
82 *dma_handle = phys_to_dma(dev, page_to_phys(page)); 97 if (force_dma_unencrypted()) {
83 memset(page_address(page), 0, size); 98 set_memory_decrypted((unsigned long)ret, 1 << page_order);
84 return page_address(page); 99 *dma_handle = __phys_to_dma(dev, page_to_phys(page));
100 } else {
101 *dma_handle = phys_to_dma(dev, page_to_phys(page));
102 }
103 memset(ret, 0, size);
104 return ret;
85} 105}
86 106
87/* 107/*
@@ -92,9 +112,12 @@ void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
92 dma_addr_t dma_addr, unsigned long attrs) 112 dma_addr_t dma_addr, unsigned long attrs)
93{ 113{
94 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; 114 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
115 unsigned int page_order = get_order(size);
95 116
117 if (force_dma_unencrypted())
118 set_memory_encrypted((unsigned long)cpu_addr, 1 << page_order);
96 if (!dma_release_from_contiguous(dev, virt_to_page(cpu_addr), count)) 119 if (!dma_release_from_contiguous(dev, virt_to_page(cpu_addr), count))
97 free_pages((unsigned long)cpu_addr, get_order(size)); 120 free_pages((unsigned long)cpu_addr, page_order);
98} 121}
99 122
100static dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, 123static dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index 4add700ddfe3..44d6b46df051 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -7,7 +7,6 @@ raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \
7raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o avx512.o recov_avx512.o 7raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o avx512.o recov_avx512.o
8raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o 8raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o
9raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o 9raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
10raid6_pq-$(CONFIG_TILEGX) += tilegx8.o
11raid6_pq-$(CONFIG_S390) += s390vx8.o recov_s390xc.o 10raid6_pq-$(CONFIG_S390) += s390vx8.o recov_s390xc.o
12 11
13hostprogs-y += mktables 12hostprogs-y += mktables
@@ -115,11 +114,6 @@ $(obj)/neon8.c: UNROLL := 8
115$(obj)/neon8.c: $(src)/neon.uc $(src)/unroll.awk FORCE 114$(obj)/neon8.c: $(src)/neon.uc $(src)/unroll.awk FORCE
116 $(call if_changed,unroll) 115 $(call if_changed,unroll)
117 116
118targets += tilegx8.c
119$(obj)/tilegx8.c: UNROLL := 8
120$(obj)/tilegx8.c: $(src)/tilegx.uc $(src)/unroll.awk FORCE
121 $(call if_changed,unroll)
122
123targets += s390vx8.c 117targets += s390vx8.c
124$(obj)/s390vx8.c: UNROLL := 8 118$(obj)/s390vx8.c: UNROLL := 8
125$(obj)/s390vx8.c: $(src)/s390vx.uc $(src)/unroll.awk FORCE 119$(obj)/s390vx8.c: $(src)/s390vx.uc $(src)/unroll.awk FORCE
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index 476994723258..c65aa80d67ed 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -75,9 +75,6 @@ const struct raid6_calls * const raid6_algos[] = {
75 &raid6_altivec4, 75 &raid6_altivec4,
76 &raid6_altivec8, 76 &raid6_altivec8,
77#endif 77#endif
78#if defined(CONFIG_TILEGX)
79 &raid6_tilegx8,
80#endif
81#if defined(CONFIG_S390) 78#if defined(CONFIG_S390)
82 &raid6_s390vx8, 79 &raid6_s390vx8,
83#endif 80#endif
diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
index be1010bdc435..fabc477b1417 100644
--- a/lib/raid6/test/Makefile
+++ b/lib/raid6/test/Makefile
@@ -51,9 +51,6 @@ else
51 OBJS += altivec1.o altivec2.o altivec4.o altivec8.o 51 OBJS += altivec1.o altivec2.o altivec4.o altivec8.o
52 endif 52 endif
53endif 53endif
54ifeq ($(ARCH),tilegx)
55OBJS += tilegx8.o
56endif
57 54
58.c.o: 55.c.o:
59 $(CC) $(CFLAGS) -c -o $@ $< 56 $(CC) $(CFLAGS) -c -o $@ $<
@@ -116,15 +113,11 @@ int16.c: int.uc ../unroll.awk
116int32.c: int.uc ../unroll.awk 113int32.c: int.uc ../unroll.awk
117 $(AWK) ../unroll.awk -vN=32 < int.uc > $@ 114 $(AWK) ../unroll.awk -vN=32 < int.uc > $@
118 115
119tilegx8.c: tilegx.uc ../unroll.awk
120 $(AWK) ../unroll.awk -vN=8 < tilegx.uc > $@
121
122tables.c: mktables 116tables.c: mktables
123 ./mktables > tables.c 117 ./mktables > tables.c
124 118
125clean: 119clean:
126 rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c neon*.c tables.c raid6test 120 rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c neon*.c tables.c raid6test
127 rm -f tilegx*.c
128 121
129spotless: clean 122spotless: clean
130 rm -f *~ 123 rm -f *~
diff --git a/lib/raid6/tilegx.uc b/lib/raid6/tilegx.uc
deleted file mode 100644
index 2dd291a11264..000000000000
--- a/lib/raid6/tilegx.uc
+++ /dev/null
@@ -1,87 +0,0 @@
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * Copyright 2002 H. Peter Anvin - All Rights Reserved
4 * Copyright 2012 Tilera Corporation - All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Boston MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
11 *
12 * ----------------------------------------------------------------------- */
13
14/*
15 * tilegx$#.c
16 *
17 * $#-way unrolled TILE-Gx SIMD for RAID-6 math.
18 *
19 * This file is postprocessed using unroll.awk.
20 *
21 */
22
23#include <linux/raid/pq.h>
24
25/* Create 8 byte copies of constant byte */
26# define NBYTES(x) (__insn_v1addi(0, x))
27# define NSIZE 8
28
29/*
30 * The SHLBYTE() operation shifts each byte left by 1, *not*
31 * rolling over into the next byte
32 */
33static inline __attribute_const__ u64 SHLBYTE(u64 v)
34{
35 /* Vector One Byte Shift Left Immediate. */
36 return __insn_v1shli(v, 1);
37}
38
39/*
40 * The MASK() operation returns 0xFF in any byte for which the high
41 * bit is 1, 0x00 for any byte for which the high bit is 0.
42 */
43static inline __attribute_const__ u64 MASK(u64 v)
44{
45 /* Vector One Byte Shift Right Signed Immediate. */
46 return __insn_v1shrsi(v, 7);
47}
48
49
50void raid6_tilegx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
51{
52 u8 **dptr = (u8 **)ptrs;
53 u64 *p, *q;
54 int d, z, z0;
55
56 u64 wd$$, wq$$, wp$$, w1$$, w2$$;
57 u64 x1d = NBYTES(0x1d);
58 u64 * z0ptr;
59
60 z0 = disks - 3; /* Highest data disk */
61 p = (u64 *)dptr[z0+1]; /* XOR parity */
62 q = (u64 *)dptr[z0+2]; /* RS syndrome */
63
64 z0ptr = (u64 *)&dptr[z0][0];
65 for ( d = 0 ; d < bytes ; d += NSIZE*$# ) {
66 wq$$ = wp$$ = *z0ptr++;
67 for ( z = z0-1 ; z >= 0 ; z-- ) {
68 wd$$ = *(u64 *)&dptr[z][d+$$*NSIZE];
69 wp$$ = wp$$ ^ wd$$;
70 w2$$ = MASK(wq$$);
71 w1$$ = SHLBYTE(wq$$);
72 w2$$ = w2$$ & x1d;
73 w1$$ = w1$$ ^ w2$$;
74 wq$$ = w1$$ ^ wd$$;
75 }
76 *p++ = wp$$;
77 *q++ = wq$$;
78 }
79}
80
81const struct raid6_calls raid6_tilegx$# = {
82 raid6_tilegx$#_gen_syndrome,
83 NULL, /* XOR not yet implemented */
84 NULL,
85 "tilegx$#",
86 0
87};
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index c43ec2271469..47aeb04c1997 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -31,6 +31,7 @@
31#include <linux/gfp.h> 31#include <linux/gfp.h>
32#include <linux/scatterlist.h> 32#include <linux/scatterlist.h>
33#include <linux/mem_encrypt.h> 33#include <linux/mem_encrypt.h>
34#include <linux/set_memory.h>
34 35
35#include <asm/io.h> 36#include <asm/io.h>
36#include <asm/dma.h> 37#include <asm/dma.h>
@@ -156,22 +157,6 @@ unsigned long swiotlb_size_or_default(void)
156 return size ? size : (IO_TLB_DEFAULT_SIZE); 157 return size ? size : (IO_TLB_DEFAULT_SIZE);
157} 158}
158 159
159void __weak swiotlb_set_mem_attributes(void *vaddr, unsigned long size) { }
160
161/* For swiotlb, clear memory encryption mask from dma addresses */
162static dma_addr_t swiotlb_phys_to_dma(struct device *hwdev,
163 phys_addr_t address)
164{
165 return __sme_clr(phys_to_dma(hwdev, address));
166}
167
168/* Note that this doesn't work with highmem page */
169static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
170 volatile void *address)
171{
172 return phys_to_dma(hwdev, virt_to_phys(address));
173}
174
175static bool no_iotlb_memory; 160static bool no_iotlb_memory;
176 161
177void swiotlb_print_info(void) 162void swiotlb_print_info(void)
@@ -209,12 +194,12 @@ void __init swiotlb_update_mem_attributes(void)
209 194
210 vaddr = phys_to_virt(io_tlb_start); 195 vaddr = phys_to_virt(io_tlb_start);
211 bytes = PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT); 196 bytes = PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT);
212 swiotlb_set_mem_attributes(vaddr, bytes); 197 set_memory_decrypted((unsigned long)vaddr, bytes >> PAGE_SHIFT);
213 memset(vaddr, 0, bytes); 198 memset(vaddr, 0, bytes);
214 199
215 vaddr = phys_to_virt(io_tlb_overflow_buffer); 200 vaddr = phys_to_virt(io_tlb_overflow_buffer);
216 bytes = PAGE_ALIGN(io_tlb_overflow); 201 bytes = PAGE_ALIGN(io_tlb_overflow);
217 swiotlb_set_mem_attributes(vaddr, bytes); 202 set_memory_decrypted((unsigned long)vaddr, bytes >> PAGE_SHIFT);
218 memset(vaddr, 0, bytes); 203 memset(vaddr, 0, bytes);
219} 204}
220 205
@@ -355,7 +340,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
355 io_tlb_start = virt_to_phys(tlb); 340 io_tlb_start = virt_to_phys(tlb);
356 io_tlb_end = io_tlb_start + bytes; 341 io_tlb_end = io_tlb_start + bytes;
357 342
358 swiotlb_set_mem_attributes(tlb, bytes); 343 set_memory_decrypted((unsigned long)tlb, bytes >> PAGE_SHIFT);
359 memset(tlb, 0, bytes); 344 memset(tlb, 0, bytes);
360 345
361 /* 346 /*
@@ -366,7 +351,8 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
366 if (!v_overflow_buffer) 351 if (!v_overflow_buffer)
367 goto cleanup2; 352 goto cleanup2;
368 353
369 swiotlb_set_mem_attributes(v_overflow_buffer, io_tlb_overflow); 354 set_memory_decrypted((unsigned long)v_overflow_buffer,
355 io_tlb_overflow >> PAGE_SHIFT);
370 memset(v_overflow_buffer, 0, io_tlb_overflow); 356 memset(v_overflow_buffer, 0, io_tlb_overflow);
371 io_tlb_overflow_buffer = virt_to_phys(v_overflow_buffer); 357 io_tlb_overflow_buffer = virt_to_phys(v_overflow_buffer);
372 358
@@ -622,7 +608,7 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size,
622 return SWIOTLB_MAP_ERROR; 608 return SWIOTLB_MAP_ERROR;
623 } 609 }
624 610
625 start_dma_addr = swiotlb_phys_to_dma(hwdev, io_tlb_start); 611 start_dma_addr = __phys_to_dma(hwdev, io_tlb_start);
626 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, 612 return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size,
627 dir, attrs); 613 dir, attrs);
628} 614}
@@ -706,6 +692,7 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr,
706 } 692 }
707} 693}
708 694
695#ifdef CONFIG_DMA_DIRECT_OPS
709static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr, 696static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr,
710 size_t size) 697 size_t size)
711{ 698{
@@ -726,12 +713,12 @@ swiotlb_alloc_buffer(struct device *dev, size_t size, dma_addr_t *dma_handle,
726 goto out_warn; 713 goto out_warn;
727 714
728 phys_addr = swiotlb_tbl_map_single(dev, 715 phys_addr = swiotlb_tbl_map_single(dev,
729 swiotlb_phys_to_dma(dev, io_tlb_start), 716 __phys_to_dma(dev, io_tlb_start),
730 0, size, DMA_FROM_DEVICE, 0); 717 0, size, DMA_FROM_DEVICE, 0);
731 if (phys_addr == SWIOTLB_MAP_ERROR) 718 if (phys_addr == SWIOTLB_MAP_ERROR)
732 goto out_warn; 719 goto out_warn;
733 720
734 *dma_handle = swiotlb_phys_to_dma(dev, phys_addr); 721 *dma_handle = __phys_to_dma(dev, phys_addr);
735 if (dma_coherent_ok(dev, *dma_handle, size)) 722 if (dma_coherent_ok(dev, *dma_handle, size))
736 goto out_unmap; 723 goto out_unmap;
737 724
@@ -759,28 +746,6 @@ out_warn:
759 return NULL; 746 return NULL;
760} 747}
761 748
762void *
763swiotlb_alloc_coherent(struct device *hwdev, size_t size,
764 dma_addr_t *dma_handle, gfp_t flags)
765{
766 int order = get_order(size);
767 unsigned long attrs = (flags & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0;
768 void *ret;
769
770 ret = (void *)__get_free_pages(flags, order);
771 if (ret) {
772 *dma_handle = swiotlb_virt_to_bus(hwdev, ret);
773 if (dma_coherent_ok(hwdev, *dma_handle, size)) {
774 memset(ret, 0, size);
775 return ret;
776 }
777 free_pages((unsigned long)ret, order);
778 }
779
780 return swiotlb_alloc_buffer(hwdev, size, dma_handle, attrs);
781}
782EXPORT_SYMBOL(swiotlb_alloc_coherent);
783
784static bool swiotlb_free_buffer(struct device *dev, size_t size, 749static bool swiotlb_free_buffer(struct device *dev, size_t size,
785 dma_addr_t dma_addr) 750 dma_addr_t dma_addr)
786{ 751{
@@ -799,15 +764,7 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size,
799 DMA_ATTR_SKIP_CPU_SYNC); 764 DMA_ATTR_SKIP_CPU_SYNC);
800 return true; 765 return true;
801} 766}
802 767#endif
803void
804swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
805 dma_addr_t dev_addr)
806{
807 if (!swiotlb_free_buffer(hwdev, size, dev_addr))
808 free_pages((unsigned long)vaddr, get_order(size));
809}
810EXPORT_SYMBOL(swiotlb_free_coherent);
811 768
812static void 769static void
813swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, 770swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
@@ -867,10 +824,10 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
867 map = map_single(dev, phys, size, dir, attrs); 824 map = map_single(dev, phys, size, dir, attrs);
868 if (map == SWIOTLB_MAP_ERROR) { 825 if (map == SWIOTLB_MAP_ERROR) {
869 swiotlb_full(dev, size, dir, 1); 826 swiotlb_full(dev, size, dir, 1);
870 return swiotlb_phys_to_dma(dev, io_tlb_overflow_buffer); 827 return __phys_to_dma(dev, io_tlb_overflow_buffer);
871 } 828 }
872 829
873 dev_addr = swiotlb_phys_to_dma(dev, map); 830 dev_addr = __phys_to_dma(dev, map);
874 831
875 /* Ensure that the address returned is DMA'ble */ 832 /* Ensure that the address returned is DMA'ble */
876 if (dma_capable(dev, dev_addr, size)) 833 if (dma_capable(dev, dev_addr, size))
@@ -879,7 +836,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
879 attrs |= DMA_ATTR_SKIP_CPU_SYNC; 836 attrs |= DMA_ATTR_SKIP_CPU_SYNC;
880 swiotlb_tbl_unmap_single(dev, map, size, dir, attrs); 837 swiotlb_tbl_unmap_single(dev, map, size, dir, attrs);
881 838
882 return swiotlb_phys_to_dma(dev, io_tlb_overflow_buffer); 839 return __phys_to_dma(dev, io_tlb_overflow_buffer);
883} 840}
884 841
885/* 842/*
@@ -1009,7 +966,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
1009 sg_dma_len(sgl) = 0; 966 sg_dma_len(sgl) = 0;
1010 return 0; 967 return 0;
1011 } 968 }
1012 sg->dma_address = swiotlb_phys_to_dma(hwdev, map); 969 sg->dma_address = __phys_to_dma(hwdev, map);
1013 } else 970 } else
1014 sg->dma_address = dev_addr; 971 sg->dma_address = dev_addr;
1015 sg_dma_len(sg) = sg->length; 972 sg_dma_len(sg) = sg->length;
@@ -1073,7 +1030,7 @@ swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
1073int 1030int
1074swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr) 1031swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
1075{ 1032{
1076 return (dma_addr == swiotlb_phys_to_dma(hwdev, io_tlb_overflow_buffer)); 1033 return (dma_addr == __phys_to_dma(hwdev, io_tlb_overflow_buffer));
1077} 1034}
1078 1035
1079/* 1036/*
@@ -1085,7 +1042,7 @@ swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
1085int 1042int
1086swiotlb_dma_supported(struct device *hwdev, u64 mask) 1043swiotlb_dma_supported(struct device *hwdev, u64 mask)
1087{ 1044{
1088 return swiotlb_phys_to_dma(hwdev, io_tlb_end - 1) <= mask; 1045 return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
1089} 1046}
1090 1047
1091#ifdef CONFIG_DMA_DIRECT_OPS 1048#ifdef CONFIG_DMA_DIRECT_OPS
diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c
index 4621db801b23..e161f0498f42 100644
--- a/lib/test_user_copy.c
+++ b/lib/test_user_copy.c
@@ -31,11 +31,8 @@
31 * their capability at compile-time, we just have to opt-out certain archs. 31 * their capability at compile-time, we just have to opt-out certain archs.
32 */ 32 */
33#if BITS_PER_LONG == 64 || (!(defined(CONFIG_ARM) && !defined(MMU)) && \ 33#if BITS_PER_LONG == 64 || (!(defined(CONFIG_ARM) && !defined(MMU)) && \
34 !defined(CONFIG_BLACKFIN) && \
35 !defined(CONFIG_M32R) && \
36 !defined(CONFIG_M68K) && \ 34 !defined(CONFIG_M68K) && \
37 !defined(CONFIG_MICROBLAZE) && \ 35 !defined(CONFIG_MICROBLAZE) && \
38 !defined(CONFIG_MN10300) && \
39 !defined(CONFIG_NIOS2) && \ 36 !defined(CONFIG_NIOS2) && \
40 !defined(CONFIG_PPC32) && \ 37 !defined(CONFIG_PPC32) && \
41 !defined(CONFIG_SUPERH)) 38 !defined(CONFIG_SUPERH))