diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2011-11-13 14:55:35 -0500 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2011-11-13 14:55:53 -0500 |
| commit | 2290c0d06d82faee87b1ab2d9d4f7bf81ef64379 (patch) | |
| tree | e075e4d5534193f28e6059904f61e5ca03958d3c /lib | |
| parent | 4da669a2e3e5bc70b30a0465f3641528681b5f77 (diff) | |
| parent | 52e4c2a05256cb83cda12f3c2137ab1533344edb (diff) | |
Merge branch 'master' into for-next
Sync with Linus tree to have 157550ff ("mtd: add GPMI-NAND driver
in the config and Makefile") as I have patch depending on that one.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig | 3 | ||||
| -rw-r--r-- | lib/Kconfig.debug | 16 | ||||
| -rw-r--r-- | lib/Makefile | 4 | ||||
| -rw-r--r-- | lib/atomic64.c | 66 | ||||
| -rw-r--r-- | lib/bitmap.c | 10 | ||||
| -rw-r--r-- | lib/dma-debug.c | 69 | ||||
| -rw-r--r-- | lib/dynamic_debug.c | 173 | ||||
| -rw-r--r-- | lib/fault-inject.c | 5 | ||||
| -rw-r--r-- | lib/idr.c | 15 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 2 | ||||
| -rw-r--r-- | lib/kstrtox.c | 75 | ||||
| -rw-r--r-- | lib/kstrtox.h | 8 | ||||
| -rw-r--r-- | lib/llist.c | 74 | ||||
| -rw-r--r-- | lib/nlattr.c | 1 | ||||
| -rw-r--r-- | lib/percpu_counter.c | 20 | ||||
| -rw-r--r-- | lib/proportions.c | 12 | ||||
| -rw-r--r-- | lib/radix-tree.c | 10 | ||||
| -rw-r--r-- | lib/raid6/algos.c | 1 | ||||
| -rw-r--r-- | lib/raid6/int.uc | 2 | ||||
| -rw-r--r-- | lib/raid6/mktables.c | 1 | ||||
| -rw-r--r-- | lib/raid6/recov.c | 1 | ||||
| -rw-r--r-- | lib/ratelimit.c | 4 | ||||
| -rw-r--r-- | lib/rwsem-spinlock.c | 38 | ||||
| -rw-r--r-- | lib/rwsem.c | 14 | ||||
| -rw-r--r-- | lib/smp_processor_id.c | 2 | ||||
| -rw-r--r-- | lib/spinlock_debug.c | 19 | ||||
| -rw-r--r-- | lib/string.c | 57 | ||||
| -rw-r--r-- | lib/vsprintf.c | 47 |
28 files changed, 459 insertions, 290 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index abff69d4ff88..d971366b8de2 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -275,7 +275,4 @@ config CORDIC | |||
| 275 | This option provides an implementation of the CORDIC algorithm; | 275 | This option provides an implementation of the CORDIC algorithm; |
| 276 | calculations are in fixed point. Module will be called cordic. | 276 | calculations are in fixed point. Module will be called cordic. |
| 277 | 277 | ||
| 278 | config LLIST | ||
| 279 | bool | ||
| 280 | |||
| 281 | endmenu | 278 | endmenu |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 75330bd87565..82928f5ea049 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -248,8 +248,9 @@ config DEFAULT_HUNG_TASK_TIMEOUT | |||
| 248 | to determine when a task has become non-responsive and should | 248 | to determine when a task has become non-responsive and should |
| 249 | be considered hung. | 249 | be considered hung. |
| 250 | 250 | ||
| 251 | It can be adjusted at runtime via the kernel.hung_task_timeout | 251 | It can be adjusted at runtime via the kernel.hung_task_timeout_secs |
| 252 | sysctl or by writing a value to /proc/sys/kernel/hung_task_timeout. | 252 | sysctl or by writing a value to |
| 253 | /proc/sys/kernel/hung_task_timeout_secs. | ||
| 253 | 254 | ||
| 254 | A timeout of 0 disables the check. The default is two minutes. | 255 | A timeout of 0 disables the check. The default is two minutes. |
| 255 | Keeping the default should be fine in most cases. | 256 | Keeping the default should be fine in most cases. |
| @@ -1070,6 +1071,17 @@ config FAIL_IO_TIMEOUT | |||
| 1070 | Only works with drivers that use the generic timeout handling, | 1071 | Only works with drivers that use the generic timeout handling, |
| 1071 | for others it wont do anything. | 1072 | for others it wont do anything. |
| 1072 | 1073 | ||
| 1074 | config FAIL_MMC_REQUEST | ||
| 1075 | bool "Fault-injection capability for MMC IO" | ||
| 1076 | select DEBUG_FS | ||
| 1077 | depends on FAULT_INJECTION && MMC | ||
| 1078 | help | ||
| 1079 | Provide fault-injection capability for MMC IO. | ||
| 1080 | This will make the mmc core return data errors. This is | ||
| 1081 | useful to test the error handling in the mmc block device | ||
| 1082 | and to test how the mmc host driver handles retries from | ||
| 1083 | the block device. | ||
| 1084 | |||
| 1073 | config FAULT_INJECTION_DEBUG_FS | 1085 | config FAULT_INJECTION_DEBUG_FS |
| 1074 | bool "Debugfs entries for fault-injection capabilities" | 1086 | bool "Debugfs entries for fault-injection capabilities" |
| 1075 | depends on FAULT_INJECTION && SYSFS && DEBUG_FS | 1087 | depends on FAULT_INJECTION && SYSFS && DEBUG_FS |
diff --git a/lib/Makefile b/lib/Makefile index 3f5bc6d903e0..a4da283f5dc0 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -22,7 +22,7 @@ lib-y += kobject.o kref.o klist.o | |||
| 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
| 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
| 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ | 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ |
| 25 | bsearch.o find_last_bit.o find_next_bit.o | 25 | bsearch.o find_last_bit.o find_next_bit.o llist.o |
| 26 | obj-y += kstrtox.o | 26 | obj-y += kstrtox.o |
| 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
| 28 | 28 | ||
| @@ -115,8 +115,6 @@ obj-$(CONFIG_CPU_RMAP) += cpu_rmap.o | |||
| 115 | 115 | ||
| 116 | obj-$(CONFIG_CORDIC) += cordic.o | 116 | obj-$(CONFIG_CORDIC) += cordic.o |
| 117 | 117 | ||
| 118 | obj-$(CONFIG_LLIST) += llist.o | ||
| 119 | |||
| 120 | hostprogs-y := gen_crc32table | 118 | hostprogs-y := gen_crc32table |
| 121 | clean-files := crc32table.h | 119 | clean-files := crc32table.h |
| 122 | 120 | ||
diff --git a/lib/atomic64.c b/lib/atomic64.c index e12ae0dd08a8..3975470caf4f 100644 --- a/lib/atomic64.c +++ b/lib/atomic64.c | |||
| @@ -29,11 +29,11 @@ | |||
| 29 | * Ensure each lock is in a separate cacheline. | 29 | * Ensure each lock is in a separate cacheline. |
| 30 | */ | 30 | */ |
| 31 | static union { | 31 | static union { |
| 32 | spinlock_t lock; | 32 | raw_spinlock_t lock; |
| 33 | char pad[L1_CACHE_BYTES]; | 33 | char pad[L1_CACHE_BYTES]; |
| 34 | } atomic64_lock[NR_LOCKS] __cacheline_aligned_in_smp; | 34 | } atomic64_lock[NR_LOCKS] __cacheline_aligned_in_smp; |
| 35 | 35 | ||
| 36 | static inline spinlock_t *lock_addr(const atomic64_t *v) | 36 | static inline raw_spinlock_t *lock_addr(const atomic64_t *v) |
| 37 | { | 37 | { |
| 38 | unsigned long addr = (unsigned long) v; | 38 | unsigned long addr = (unsigned long) v; |
| 39 | 39 | ||
| @@ -45,12 +45,12 @@ static inline spinlock_t *lock_addr(const atomic64_t *v) | |||
| 45 | long long atomic64_read(const atomic64_t *v) | 45 | long long atomic64_read(const atomic64_t *v) |
| 46 | { | 46 | { |
| 47 | unsigned long flags; | 47 | unsigned long flags; |
| 48 | spinlock_t *lock = lock_addr(v); | 48 | raw_spinlock_t *lock = lock_addr(v); |
| 49 | long long val; | 49 | long long val; |
| 50 | 50 | ||
| 51 | spin_lock_irqsave(lock, flags); | 51 | raw_spin_lock_irqsave(lock, flags); |
| 52 | val = v->counter; | 52 | val = v->counter; |
| 53 | spin_unlock_irqrestore(lock, flags); | 53 | raw_spin_unlock_irqrestore(lock, flags); |
| 54 | return val; | 54 | return val; |
| 55 | } | 55 | } |
| 56 | EXPORT_SYMBOL(atomic64_read); | 56 | EXPORT_SYMBOL(atomic64_read); |
| @@ -58,34 +58,34 @@ EXPORT_SYMBOL(atomic64_read); | |||
| 58 | void atomic64_set(atomic64_t *v, long long i) | 58 | void atomic64_set(atomic64_t *v, long long i) |
| 59 | { | 59 | { |
| 60 | unsigned long flags; | 60 | unsigned long flags; |
| 61 | spinlock_t *lock = lock_addr(v); | 61 | raw_spinlock_t *lock = lock_addr(v); |
| 62 | 62 | ||
| 63 | spin_lock_irqsave(lock, flags); | 63 | raw_spin_lock_irqsave(lock, flags); |
| 64 | v->counter = i; | 64 | v->counter = i; |
| 65 | spin_unlock_irqrestore(lock, flags); | 65 | raw_spin_unlock_irqrestore(lock, flags); |
| 66 | } | 66 | } |
| 67 | EXPORT_SYMBOL(atomic64_set); | 67 | EXPORT_SYMBOL(atomic64_set); |
| 68 | 68 | ||
| 69 | void atomic64_add(long long a, atomic64_t *v) | 69 | void atomic64_add(long long a, atomic64_t *v) |
| 70 | { | 70 | { |
| 71 | unsigned long flags; | 71 | unsigned long flags; |
| 72 | spinlock_t *lock = lock_addr(v); | 72 | raw_spinlock_t *lock = lock_addr(v); |
| 73 | 73 | ||
| 74 | spin_lock_irqsave(lock, flags); | 74 | raw_spin_lock_irqsave(lock, flags); |
| 75 | v->counter += a; | 75 | v->counter += a; |
| 76 | spin_unlock_irqrestore(lock, flags); | 76 | raw_spin_unlock_irqrestore(lock, flags); |
| 77 | } | 77 | } |
| 78 | EXPORT_SYMBOL(atomic64_add); | 78 | EXPORT_SYMBOL(atomic64_add); |
| 79 | 79 | ||
| 80 | long long atomic64_add_return(long long a, atomic64_t *v) | 80 | long long atomic64_add_return(long long a, atomic64_t *v) |
| 81 | { | 81 | { |
| 82 | unsigned long flags; | 82 | unsigned long flags; |
| 83 | spinlock_t *lock = lock_addr(v); | 83 | raw_spinlock_t *lock = lock_addr(v); |
| 84 | long long val; | 84 | long long val; |
| 85 | 85 | ||
| 86 | spin_lock_irqsave(lock, flags); | 86 | raw_spin_lock_irqsave(lock, flags); |
| 87 | val = v->counter += a; | 87 | val = v->counter += a; |
| 88 | spin_unlock_irqrestore(lock, flags); | 88 | raw_spin_unlock_irqrestore(lock, flags); |
| 89 | return val; | 89 | return val; |
| 90 | } | 90 | } |
| 91 | EXPORT_SYMBOL(atomic64_add_return); | 91 | EXPORT_SYMBOL(atomic64_add_return); |
| @@ -93,23 +93,23 @@ EXPORT_SYMBOL(atomic64_add_return); | |||
| 93 | void atomic64_sub(long long a, atomic64_t *v) | 93 | void atomic64_sub(long long a, atomic64_t *v) |
| 94 | { | 94 | { |
| 95 | unsigned long flags; | 95 | unsigned long flags; |
| 96 | spinlock_t *lock = lock_addr(v); | 96 | raw_spinlock_t *lock = lock_addr(v); |
| 97 | 97 | ||
| 98 | spin_lock_irqsave(lock, flags); | 98 | raw_spin_lock_irqsave(lock, flags); |
| 99 | v->counter -= a; | 99 | v->counter -= a; |
| 100 | spin_unlock_irqrestore(lock, flags); | 100 | raw_spin_unlock_irqrestore(lock, flags); |
| 101 | } | 101 | } |
| 102 | EXPORT_SYMBOL(atomic64_sub); | 102 | EXPORT_SYMBOL(atomic64_sub); |
| 103 | 103 | ||
| 104 | long long atomic64_sub_return(long long a, atomic64_t *v) | 104 | long long atomic64_sub_return(long long a, atomic64_t *v) |
| 105 | { | 105 | { |
| 106 | unsigned long flags; | 106 | unsigned long flags; |
| 107 | spinlock_t *lock = lock_addr(v); | 107 | raw_spinlock_t *lock = lock_addr(v); |
| 108 | long long val; | 108 | long long val; |
| 109 | 109 | ||
| 110 | spin_lock_irqsave(lock, flags); | 110 | raw_spin_lock_irqsave(lock, flags); |
| 111 | val = v->counter -= a; | 111 | val = v->counter -= a; |
| 112 | spin_unlock_irqrestore(lock, flags); | 112 | raw_spin_unlock_irqrestore(lock, flags); |
| 113 | return val; | 113 | return val; |
| 114 | } | 114 | } |
| 115 | EXPORT_SYMBOL(atomic64_sub_return); | 115 | EXPORT_SYMBOL(atomic64_sub_return); |
| @@ -117,14 +117,14 @@ EXPORT_SYMBOL(atomic64_sub_return); | |||
| 117 | long long atomic64_dec_if_positive(atomic64_t *v) | 117 | long long atomic64_dec_if_positive(atomic64_t *v) |
| 118 | { | 118 | { |
| 119 | unsigned long flags; | 119 | unsigned long flags; |
| 120 | spinlock_t *lock = lock_addr(v); | 120 | raw_spinlock_t *lock = lock_addr(v); |
| 121 | long long val; | 121 | long long val; |
| 122 | 122 | ||
| 123 | spin_lock_irqsave(lock, flags); | 123 | raw_spin_lock_irqsave(lock, flags); |
| 124 | val = v->counter - 1; | 124 | val = v->counter - 1; |
| 125 | if (val >= 0) | 125 | if (val >= 0) |
| 126 | v->counter = val; | 126 | v->counter = val; |
| 127 | spin_unlock_irqrestore(lock, flags); | 127 | raw_spin_unlock_irqrestore(lock, flags); |
| 128 | return val; | 128 | return val; |
| 129 | } | 129 | } |
| 130 | EXPORT_SYMBOL(atomic64_dec_if_positive); | 130 | EXPORT_SYMBOL(atomic64_dec_if_positive); |
| @@ -132,14 +132,14 @@ EXPORT_SYMBOL(atomic64_dec_if_positive); | |||
| 132 | long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n) | 132 | long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n) |
| 133 | { | 133 | { |
| 134 | unsigned long flags; | 134 | unsigned long flags; |
| 135 | spinlock_t *lock = lock_addr(v); | 135 | raw_spinlock_t *lock = lock_addr(v); |
| 136 | long long val; | 136 | long long val; |
| 137 | 137 | ||
| 138 | spin_lock_irqsave(lock, flags); | 138 | raw_spin_lock_irqsave(lock, flags); |
| 139 | val = v->counter; | 139 | val = v->counter; |
| 140 | if (val == o) | 140 | if (val == o) |
| 141 | v->counter = n; | 141 | v->counter = n; |
| 142 | spin_unlock_irqrestore(lock, flags); | 142 | raw_spin_unlock_irqrestore(lock, flags); |
| 143 | return val; | 143 | return val; |
| 144 | } | 144 | } |
| 145 | EXPORT_SYMBOL(atomic64_cmpxchg); | 145 | EXPORT_SYMBOL(atomic64_cmpxchg); |
| @@ -147,13 +147,13 @@ EXPORT_SYMBOL(atomic64_cmpxchg); | |||
| 147 | long long atomic64_xchg(atomic64_t *v, long long new) | 147 | long long atomic64_xchg(atomic64_t *v, long long new) |
| 148 | { | 148 | { |
| 149 | unsigned long flags; | 149 | unsigned long flags; |
| 150 | spinlock_t *lock = lock_addr(v); | 150 | raw_spinlock_t *lock = lock_addr(v); |
| 151 | long long val; | 151 | long long val; |
| 152 | 152 | ||
| 153 | spin_lock_irqsave(lock, flags); | 153 | raw_spin_lock_irqsave(lock, flags); |
| 154 | val = v->counter; | 154 | val = v->counter; |
| 155 | v->counter = new; | 155 | v->counter = new; |
| 156 | spin_unlock_irqrestore(lock, flags); | 156 | raw_spin_unlock_irqrestore(lock, flags); |
| 157 | return val; | 157 | return val; |
| 158 | } | 158 | } |
| 159 | EXPORT_SYMBOL(atomic64_xchg); | 159 | EXPORT_SYMBOL(atomic64_xchg); |
| @@ -161,15 +161,15 @@ EXPORT_SYMBOL(atomic64_xchg); | |||
| 161 | int atomic64_add_unless(atomic64_t *v, long long a, long long u) | 161 | int atomic64_add_unless(atomic64_t *v, long long a, long long u) |
| 162 | { | 162 | { |
| 163 | unsigned long flags; | 163 | unsigned long flags; |
| 164 | spinlock_t *lock = lock_addr(v); | 164 | raw_spinlock_t *lock = lock_addr(v); |
| 165 | int ret = 0; | 165 | int ret = 0; |
| 166 | 166 | ||
| 167 | spin_lock_irqsave(lock, flags); | 167 | raw_spin_lock_irqsave(lock, flags); |
| 168 | if (v->counter != u) { | 168 | if (v->counter != u) { |
| 169 | v->counter += a; | 169 | v->counter += a; |
| 170 | ret = 1; | 170 | ret = 1; |
| 171 | } | 171 | } |
| 172 | spin_unlock_irqrestore(lock, flags); | 172 | raw_spin_unlock_irqrestore(lock, flags); |
| 173 | return ret; | 173 | return ret; |
| 174 | } | 174 | } |
| 175 | EXPORT_SYMBOL(atomic64_add_unless); | 175 | EXPORT_SYMBOL(atomic64_add_unless); |
| @@ -179,7 +179,7 @@ static int init_atomic64_lock(void) | |||
| 179 | int i; | 179 | int i; |
| 180 | 180 | ||
| 181 | for (i = 0; i < NR_LOCKS; ++i) | 181 | for (i = 0; i < NR_LOCKS; ++i) |
| 182 | spin_lock_init(&atomic64_lock[i].lock); | 182 | raw_spin_lock_init(&atomic64_lock[i].lock); |
| 183 | return 0; | 183 | return 0; |
| 184 | } | 184 | } |
| 185 | 185 | ||
diff --git a/lib/bitmap.c b/lib/bitmap.c index 2f4412e4d071..0d4a127dd9b3 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
| @@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen, | |||
| 419 | { | 419 | { |
| 420 | int c, old_c, totaldigits, ndigits, nchunks, nbits; | 420 | int c, old_c, totaldigits, ndigits, nchunks, nbits; |
| 421 | u32 chunk; | 421 | u32 chunk; |
| 422 | const char __user *ubuf = buf; | 422 | const char __user __force *ubuf = (const char __user __force *)buf; |
| 423 | 423 | ||
| 424 | bitmap_zero(maskp, nmaskbits); | 424 | bitmap_zero(maskp, nmaskbits); |
| 425 | 425 | ||
| @@ -504,7 +504,9 @@ int bitmap_parse_user(const char __user *ubuf, | |||
| 504 | { | 504 | { |
| 505 | if (!access_ok(VERIFY_READ, ubuf, ulen)) | 505 | if (!access_ok(VERIFY_READ, ubuf, ulen)) |
| 506 | return -EFAULT; | 506 | return -EFAULT; |
| 507 | return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits); | 507 | return __bitmap_parse((const char __force *)ubuf, |
| 508 | ulen, 1, maskp, nmaskbits); | ||
| 509 | |||
| 508 | } | 510 | } |
| 509 | EXPORT_SYMBOL(bitmap_parse_user); | 511 | EXPORT_SYMBOL(bitmap_parse_user); |
| 510 | 512 | ||
| @@ -594,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
| 594 | { | 596 | { |
| 595 | unsigned a, b; | 597 | unsigned a, b; |
| 596 | int c, old_c, totaldigits; | 598 | int c, old_c, totaldigits; |
| 597 | const char __user *ubuf = buf; | 599 | const char __user __force *ubuf = (const char __user __force *)buf; |
| 598 | int exp_digit, in_range; | 600 | int exp_digit, in_range; |
| 599 | 601 | ||
| 600 | totaldigits = c = 0; | 602 | totaldigits = c = 0; |
| @@ -694,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf, | |||
| 694 | { | 696 | { |
| 695 | if (!access_ok(VERIFY_READ, ubuf, ulen)) | 697 | if (!access_ok(VERIFY_READ, ubuf, ulen)) |
| 696 | return -EFAULT; | 698 | return -EFAULT; |
| 697 | return __bitmap_parselist((const char *)ubuf, | 699 | return __bitmap_parselist((const char __force *)ubuf, |
| 698 | ulen, 1, maskp, nmaskbits); | 700 | ulen, 1, maskp, nmaskbits); |
| 699 | } | 701 | } |
| 700 | EXPORT_SYMBOL(bitmap_parselist_user); | 702 | EXPORT_SYMBOL(bitmap_parselist_user); |
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index db07bfd9298e..74c6c7fce749 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
| 25 | #include <linux/debugfs.h> | 25 | #include <linux/debugfs.h> |
| 26 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
| 27 | #include <linux/export.h> | ||
| 27 | #include <linux/device.h> | 28 | #include <linux/device.h> |
| 28 | #include <linux/types.h> | 29 | #include <linux/types.h> |
| 29 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
| @@ -62,6 +63,8 @@ struct dma_debug_entry { | |||
| 62 | #endif | 63 | #endif |
| 63 | }; | 64 | }; |
| 64 | 65 | ||
| 66 | typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *); | ||
| 67 | |||
| 65 | struct hash_bucket { | 68 | struct hash_bucket { |
| 66 | struct list_head list; | 69 | struct list_head list; |
| 67 | spinlock_t lock; | 70 | spinlock_t lock; |
| @@ -240,18 +243,37 @@ static void put_hash_bucket(struct hash_bucket *bucket, | |||
| 240 | spin_unlock_irqrestore(&bucket->lock, __flags); | 243 | spin_unlock_irqrestore(&bucket->lock, __flags); |
| 241 | } | 244 | } |
| 242 | 245 | ||
| 246 | static bool exact_match(struct dma_debug_entry *a, struct dma_debug_entry *b) | ||
| 247 | { | ||
| 248 | return ((a->dev_addr == a->dev_addr) && | ||
| 249 | (a->dev == b->dev)) ? true : false; | ||
| 250 | } | ||
| 251 | |||
| 252 | static bool containing_match(struct dma_debug_entry *a, | ||
| 253 | struct dma_debug_entry *b) | ||
| 254 | { | ||
| 255 | if (a->dev != b->dev) | ||
| 256 | return false; | ||
| 257 | |||
| 258 | if ((b->dev_addr <= a->dev_addr) && | ||
| 259 | ((b->dev_addr + b->size) >= (a->dev_addr + a->size))) | ||
| 260 | return true; | ||
| 261 | |||
| 262 | return false; | ||
| 263 | } | ||
| 264 | |||
| 243 | /* | 265 | /* |
| 244 | * Search a given entry in the hash bucket list | 266 | * Search a given entry in the hash bucket list |
| 245 | */ | 267 | */ |
| 246 | static struct dma_debug_entry *hash_bucket_find(struct hash_bucket *bucket, | 268 | static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket, |
| 247 | struct dma_debug_entry *ref) | 269 | struct dma_debug_entry *ref, |
| 270 | match_fn match) | ||
| 248 | { | 271 | { |
| 249 | struct dma_debug_entry *entry, *ret = NULL; | 272 | struct dma_debug_entry *entry, *ret = NULL; |
| 250 | int matches = 0, match_lvl, last_lvl = 0; | 273 | int matches = 0, match_lvl, last_lvl = 0; |
| 251 | 274 | ||
| 252 | list_for_each_entry(entry, &bucket->list, list) { | 275 | list_for_each_entry(entry, &bucket->list, list) { |
| 253 | if ((entry->dev_addr != ref->dev_addr) || | 276 | if (!match(ref, entry)) |
| 254 | (entry->dev != ref->dev)) | ||
| 255 | continue; | 277 | continue; |
| 256 | 278 | ||
| 257 | /* | 279 | /* |
| @@ -293,6 +315,39 @@ static struct dma_debug_entry *hash_bucket_find(struct hash_bucket *bucket, | |||
| 293 | return ret; | 315 | return ret; |
| 294 | } | 316 | } |
| 295 | 317 | ||
| 318 | static struct dma_debug_entry *bucket_find_exact(struct hash_bucket *bucket, | ||
| 319 | struct dma_debug_entry *ref) | ||
| 320 | { | ||
| 321 | return __hash_bucket_find(bucket, ref, exact_match); | ||
| 322 | } | ||
| 323 | |||
| 324 | static struct dma_debug_entry *bucket_find_contain(struct hash_bucket **bucket, | ||
| 325 | struct dma_debug_entry *ref, | ||
| 326 | unsigned long *flags) | ||
| 327 | { | ||
| 328 | |||
| 329 | unsigned int max_range = dma_get_max_seg_size(ref->dev); | ||
| 330 | struct dma_debug_entry *entry, index = *ref; | ||
| 331 | unsigned int range = 0; | ||
| 332 | |||
| 333 | while (range <= max_range) { | ||
| 334 | entry = __hash_bucket_find(*bucket, &index, containing_match); | ||
| 335 | |||
| 336 | if (entry) | ||
| 337 | return entry; | ||
| 338 | |||
| 339 | /* | ||
| 340 | * Nothing found, go back a hash bucket | ||
| 341 | */ | ||
| 342 | put_hash_bucket(*bucket, flags); | ||
| 343 | range += (1 << HASH_FN_SHIFT); | ||
| 344 | index.dev_addr -= (1 << HASH_FN_SHIFT); | ||
| 345 | *bucket = get_hash_bucket(&index, flags); | ||
| 346 | } | ||
| 347 | |||
| 348 | return NULL; | ||
| 349 | } | ||
| 350 | |||
| 296 | /* | 351 | /* |
| 297 | * Add an entry to a hash bucket | 352 | * Add an entry to a hash bucket |
| 298 | */ | 353 | */ |
| @@ -802,7 +857,7 @@ static void check_unmap(struct dma_debug_entry *ref) | |||
| 802 | } | 857 | } |
| 803 | 858 | ||
| 804 | bucket = get_hash_bucket(ref, &flags); | 859 | bucket = get_hash_bucket(ref, &flags); |
| 805 | entry = hash_bucket_find(bucket, ref); | 860 | entry = bucket_find_exact(bucket, ref); |
| 806 | 861 | ||
| 807 | if (!entry) { | 862 | if (!entry) { |
| 808 | err_printk(ref->dev, NULL, "DMA-API: device driver tries " | 863 | err_printk(ref->dev, NULL, "DMA-API: device driver tries " |
| @@ -902,7 +957,7 @@ static void check_sync(struct device *dev, | |||
| 902 | 957 | ||
| 903 | bucket = get_hash_bucket(ref, &flags); | 958 | bucket = get_hash_bucket(ref, &flags); |
| 904 | 959 | ||
| 905 | entry = hash_bucket_find(bucket, ref); | 960 | entry = bucket_find_contain(&bucket, ref, &flags); |
| 906 | 961 | ||
| 907 | if (!entry) { | 962 | if (!entry) { |
| 908 | err_printk(dev, NULL, "DMA-API: device driver tries " | 963 | err_printk(dev, NULL, "DMA-API: device driver tries " |
| @@ -1060,7 +1115,7 @@ static int get_nr_mapped_entries(struct device *dev, | |||
| 1060 | int mapped_ents; | 1115 | int mapped_ents; |
| 1061 | 1116 | ||
| 1062 | bucket = get_hash_bucket(ref, &flags); | 1117 | bucket = get_hash_bucket(ref, &flags); |
| 1063 | entry = hash_bucket_find(bucket, ref); | 1118 | entry = bucket_find_exact(bucket, ref); |
| 1064 | mapped_ents = 0; | 1119 | mapped_ents = 0; |
| 1065 | 1120 | ||
| 1066 | if (entry) | 1121 | if (entry) |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 79fc20b65e74..dcdade39e47f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * Copyright (C) 2011 Bart Van Assche. All Rights Reserved. | 10 | * Copyright (C) 2011 Bart Van Assche. All Rights Reserved. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
| 14 | |||
| 13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 15 | #include <linux/moduleparam.h> | 17 | #include <linux/moduleparam.h> |
| @@ -29,6 +31,8 @@ | |||
| 29 | #include <linux/jump_label.h> | 31 | #include <linux/jump_label.h> |
| 30 | #include <linux/hardirq.h> | 32 | #include <linux/hardirq.h> |
| 31 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
| 34 | #include <linux/device.h> | ||
| 35 | #include <linux/netdevice.h> | ||
| 32 | 36 | ||
| 33 | extern struct _ddebug __start___verbose[]; | 37 | extern struct _ddebug __start___verbose[]; |
| 34 | extern struct _ddebug __stop___verbose[]; | 38 | extern struct _ddebug __stop___verbose[]; |
| @@ -37,7 +41,6 @@ struct ddebug_table { | |||
| 37 | struct list_head link; | 41 | struct list_head link; |
| 38 | char *mod_name; | 42 | char *mod_name; |
| 39 | unsigned int num_ddebugs; | 43 | unsigned int num_ddebugs; |
| 40 | unsigned int num_enabled; | ||
| 41 | struct _ddebug *ddebugs; | 44 | struct _ddebug *ddebugs; |
| 42 | }; | 45 | }; |
| 43 | 46 | ||
| @@ -147,19 +150,13 @@ static void ddebug_change(const struct ddebug_query *query, | |||
| 147 | newflags = (dp->flags & mask) | flags; | 150 | newflags = (dp->flags & mask) | flags; |
| 148 | if (newflags == dp->flags) | 151 | if (newflags == dp->flags) |
| 149 | continue; | 152 | continue; |
| 150 | |||
| 151 | if (!newflags) | ||
| 152 | dt->num_enabled--; | ||
| 153 | else if (!dp->flags) | ||
| 154 | dt->num_enabled++; | ||
| 155 | dp->flags = newflags; | 153 | dp->flags = newflags; |
| 156 | if (newflags) | 154 | if (newflags) |
| 157 | dp->enabled = 1; | 155 | dp->enabled = 1; |
| 158 | else | 156 | else |
| 159 | dp->enabled = 0; | 157 | dp->enabled = 0; |
| 160 | if (verbose) | 158 | if (verbose) |
| 161 | printk(KERN_INFO | 159 | pr_info("changed %s:%d [%s]%s %s\n", |
| 162 | "ddebug: changed %s:%d [%s]%s %s\n", | ||
| 163 | dp->filename, dp->lineno, | 160 | dp->filename, dp->lineno, |
| 164 | dt->mod_name, dp->function, | 161 | dt->mod_name, dp->function, |
| 165 | ddebug_describe_flags(dp, flagbuf, | 162 | ddebug_describe_flags(dp, flagbuf, |
| @@ -169,7 +166,7 @@ static void ddebug_change(const struct ddebug_query *query, | |||
| 169 | mutex_unlock(&ddebug_lock); | 166 | mutex_unlock(&ddebug_lock); |
| 170 | 167 | ||
| 171 | if (!nfound && verbose) | 168 | if (!nfound && verbose) |
| 172 | printk(KERN_INFO "ddebug: no matches for query\n"); | 169 | pr_info("no matches for query\n"); |
| 173 | } | 170 | } |
| 174 | 171 | ||
| 175 | /* | 172 | /* |
| @@ -214,10 +211,10 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) | |||
| 214 | 211 | ||
| 215 | if (verbose) { | 212 | if (verbose) { |
| 216 | int i; | 213 | int i; |
| 217 | printk(KERN_INFO "%s: split into words:", __func__); | 214 | pr_info("split into words:"); |
| 218 | for (i = 0 ; i < nwords ; i++) | 215 | for (i = 0 ; i < nwords ; i++) |
| 219 | printk(" \"%s\"", words[i]); | 216 | pr_cont(" \"%s\"", words[i]); |
| 220 | printk("\n"); | 217 | pr_cont("\n"); |
| 221 | } | 218 | } |
| 222 | 219 | ||
| 223 | return nwords; | 220 | return nwords; |
| @@ -329,16 +326,15 @@ static int ddebug_parse_query(char *words[], int nwords, | |||
| 329 | } | 326 | } |
| 330 | } else { | 327 | } else { |
| 331 | if (verbose) | 328 | if (verbose) |
| 332 | printk(KERN_ERR "%s: unknown keyword \"%s\"\n", | 329 | pr_err("unknown keyword \"%s\"\n", words[i]); |
| 333 | __func__, words[i]); | ||
| 334 | return -EINVAL; | 330 | return -EINVAL; |
| 335 | } | 331 | } |
| 336 | } | 332 | } |
| 337 | 333 | ||
| 338 | if (verbose) | 334 | if (verbose) |
| 339 | printk(KERN_INFO "%s: q->function=\"%s\" q->filename=\"%s\" " | 335 | pr_info("q->function=\"%s\" q->filename=\"%s\" " |
| 340 | "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n", | 336 | "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n", |
| 341 | __func__, query->function, query->filename, | 337 | query->function, query->filename, |
| 342 | query->module, query->format, query->first_lineno, | 338 | query->module, query->format, query->first_lineno, |
| 343 | query->last_lineno); | 339 | query->last_lineno); |
| 344 | 340 | ||
| @@ -367,7 +363,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
| 367 | return -EINVAL; | 363 | return -EINVAL; |
| 368 | } | 364 | } |
| 369 | if (verbose) | 365 | if (verbose) |
| 370 | printk(KERN_INFO "%s: op='%c'\n", __func__, op); | 366 | pr_info("op='%c'\n", op); |
| 371 | 367 | ||
| 372 | for ( ; *str ; ++str) { | 368 | for ( ; *str ; ++str) { |
| 373 | for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { | 369 | for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { |
| @@ -382,7 +378,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
| 382 | if (flags == 0) | 378 | if (flags == 0) |
| 383 | return -EINVAL; | 379 | return -EINVAL; |
| 384 | if (verbose) | 380 | if (verbose) |
| 385 | printk(KERN_INFO "%s: flags=0x%x\n", __func__, flags); | 381 | pr_info("flags=0x%x\n", flags); |
| 386 | 382 | ||
| 387 | /* calculate final *flagsp, *maskp according to mask and op */ | 383 | /* calculate final *flagsp, *maskp according to mask and op */ |
| 388 | switch (op) { | 384 | switch (op) { |
| @@ -400,8 +396,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
| 400 | break; | 396 | break; |
| 401 | } | 397 | } |
| 402 | if (verbose) | 398 | if (verbose) |
| 403 | printk(KERN_INFO "%s: *flagsp=0x%x *maskp=0x%x\n", | 399 | pr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp); |
| 404 | __func__, *flagsp, *maskp); | ||
| 405 | return 0; | 400 | return 0; |
| 406 | } | 401 | } |
| 407 | 402 | ||
| @@ -426,40 +421,117 @@ static int ddebug_exec_query(char *query_string) | |||
| 426 | return 0; | 421 | return 0; |
| 427 | } | 422 | } |
| 428 | 423 | ||
| 424 | #define PREFIX_SIZE 64 | ||
| 425 | |||
| 426 | static int remaining(int wrote) | ||
| 427 | { | ||
| 428 | if (PREFIX_SIZE - wrote > 0) | ||
| 429 | return PREFIX_SIZE - wrote; | ||
| 430 | return 0; | ||
| 431 | } | ||
| 432 | |||
| 433 | static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) | ||
| 434 | { | ||
| 435 | int pos_after_tid; | ||
| 436 | int pos = 0; | ||
| 437 | |||
| 438 | pos += snprintf(buf + pos, remaining(pos), "%s", KERN_DEBUG); | ||
| 439 | if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { | ||
| 440 | if (in_interrupt()) | ||
| 441 | pos += snprintf(buf + pos, remaining(pos), "%s ", | ||
| 442 | "<intr>"); | ||
| 443 | else | ||
| 444 | pos += snprintf(buf + pos, remaining(pos), "[%d] ", | ||
| 445 | task_pid_vnr(current)); | ||
| 446 | } | ||
| 447 | pos_after_tid = pos; | ||
| 448 | if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) | ||
| 449 | pos += snprintf(buf + pos, remaining(pos), "%s:", | ||
| 450 | desc->modname); | ||
| 451 | if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) | ||
| 452 | pos += snprintf(buf + pos, remaining(pos), "%s:", | ||
| 453 | desc->function); | ||
| 454 | if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) | ||
| 455 | pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); | ||
| 456 | if (pos - pos_after_tid) | ||
| 457 | pos += snprintf(buf + pos, remaining(pos), " "); | ||
| 458 | if (pos >= PREFIX_SIZE) | ||
| 459 | buf[PREFIX_SIZE - 1] = '\0'; | ||
| 460 | |||
| 461 | return buf; | ||
| 462 | } | ||
| 463 | |||
| 429 | int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) | 464 | int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) |
| 430 | { | 465 | { |
| 431 | va_list args; | 466 | va_list args; |
| 432 | int res; | 467 | int res; |
| 468 | struct va_format vaf; | ||
| 469 | char buf[PREFIX_SIZE]; | ||
| 433 | 470 | ||
| 434 | BUG_ON(!descriptor); | 471 | BUG_ON(!descriptor); |
| 435 | BUG_ON(!fmt); | 472 | BUG_ON(!fmt); |
| 436 | 473 | ||
| 437 | va_start(args, fmt); | 474 | va_start(args, fmt); |
| 438 | res = printk(KERN_DEBUG); | 475 | vaf.fmt = fmt; |
| 439 | if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) { | 476 | vaf.va = &args; |
| 440 | if (in_interrupt()) | 477 | res = printk("%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); |
| 441 | res += printk(KERN_CONT "<intr> "); | ||
| 442 | else | ||
| 443 | res += printk(KERN_CONT "[%d] ", task_pid_vnr(current)); | ||
| 444 | } | ||
| 445 | if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) | ||
| 446 | res += printk(KERN_CONT "%s:", descriptor->modname); | ||
| 447 | if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) | ||
| 448 | res += printk(KERN_CONT "%s:", descriptor->function); | ||
| 449 | if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO) | ||
| 450 | res += printk(KERN_CONT "%d ", descriptor->lineno); | ||
| 451 | res += vprintk(fmt, args); | ||
| 452 | va_end(args); | 478 | va_end(args); |
| 453 | 479 | ||
| 454 | return res; | 480 | return res; |
| 455 | } | 481 | } |
| 456 | EXPORT_SYMBOL(__dynamic_pr_debug); | 482 | EXPORT_SYMBOL(__dynamic_pr_debug); |
| 457 | 483 | ||
| 484 | int __dynamic_dev_dbg(struct _ddebug *descriptor, | ||
| 485 | const struct device *dev, const char *fmt, ...) | ||
| 486 | { | ||
| 487 | struct va_format vaf; | ||
| 488 | va_list args; | ||
| 489 | int res; | ||
| 490 | char buf[PREFIX_SIZE]; | ||
| 491 | |||
| 492 | BUG_ON(!descriptor); | ||
| 493 | BUG_ON(!fmt); | ||
| 494 | |||
| 495 | va_start(args, fmt); | ||
| 496 | vaf.fmt = fmt; | ||
| 497 | vaf.va = &args; | ||
| 498 | res = __dev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); | ||
| 499 | va_end(args); | ||
| 500 | |||
| 501 | return res; | ||
| 502 | } | ||
| 503 | EXPORT_SYMBOL(__dynamic_dev_dbg); | ||
| 504 | |||
| 505 | #ifdef CONFIG_NET | ||
| 506 | |||
| 507 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | ||
| 508 | const struct net_device *dev, const char *fmt, ...) | ||
| 509 | { | ||
| 510 | struct va_format vaf; | ||
| 511 | va_list args; | ||
| 512 | int res; | ||
| 513 | char buf[PREFIX_SIZE]; | ||
| 514 | |||
| 515 | BUG_ON(!descriptor); | ||
| 516 | BUG_ON(!fmt); | ||
| 517 | |||
| 518 | va_start(args, fmt); | ||
| 519 | vaf.fmt = fmt; | ||
| 520 | vaf.va = &args; | ||
| 521 | res = __netdev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); | ||
| 522 | va_end(args); | ||
| 523 | |||
| 524 | return res; | ||
| 525 | } | ||
| 526 | EXPORT_SYMBOL(__dynamic_netdev_dbg); | ||
| 527 | |||
| 528 | #endif | ||
| 529 | |||
| 458 | static __initdata char ddebug_setup_string[1024]; | 530 | static __initdata char ddebug_setup_string[1024]; |
| 459 | static __init int ddebug_setup_query(char *str) | 531 | static __init int ddebug_setup_query(char *str) |
| 460 | { | 532 | { |
| 461 | if (strlen(str) >= 1024) { | 533 | if (strlen(str) >= 1024) { |
| 462 | pr_warning("ddebug boot param string too large\n"); | 534 | pr_warn("ddebug boot param string too large\n"); |
| 463 | return 0; | 535 | return 0; |
| 464 | } | 536 | } |
| 465 | strcpy(ddebug_setup_string, str); | 537 | strcpy(ddebug_setup_string, str); |
| @@ -487,8 +559,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, | |||
| 487 | return -EFAULT; | 559 | return -EFAULT; |
| 488 | tmpbuf[len] = '\0'; | 560 | tmpbuf[len] = '\0'; |
| 489 | if (verbose) | 561 | if (verbose) |
| 490 | printk(KERN_INFO "%s: read %d bytes from userspace\n", | 562 | pr_info("read %d bytes from userspace\n", (int)len); |
| 491 | __func__, (int)len); | ||
| 492 | 563 | ||
| 493 | ret = ddebug_exec_query(tmpbuf); | 564 | ret = ddebug_exec_query(tmpbuf); |
| 494 | if (ret) | 565 | if (ret) |
| @@ -551,8 +622,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos) | |||
| 551 | int n = *pos; | 622 | int n = *pos; |
| 552 | 623 | ||
| 553 | if (verbose) | 624 | if (verbose) |
| 554 | printk(KERN_INFO "%s: called m=%p *pos=%lld\n", | 625 | pr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos); |
| 555 | __func__, m, (unsigned long long)*pos); | ||
| 556 | 626 | ||
| 557 | mutex_lock(&ddebug_lock); | 627 | mutex_lock(&ddebug_lock); |
| 558 | 628 | ||
| @@ -577,8 +647,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) | |||
| 577 | struct _ddebug *dp; | 647 | struct _ddebug *dp; |
| 578 | 648 | ||
| 579 | if (verbose) | 649 | if (verbose) |
| 580 | printk(KERN_INFO "%s: called m=%p p=%p *pos=%lld\n", | 650 | pr_info("called m=%p p=%p *pos=%lld\n", |
| 581 | __func__, m, p, (unsigned long long)*pos); | 651 | m, p, (unsigned long long)*pos); |
| 582 | 652 | ||
| 583 | if (p == SEQ_START_TOKEN) | 653 | if (p == SEQ_START_TOKEN) |
| 584 | dp = ddebug_iter_first(iter); | 654 | dp = ddebug_iter_first(iter); |
| @@ -601,8 +671,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) | |||
| 601 | char flagsbuf[8]; | 671 | char flagsbuf[8]; |
| 602 | 672 | ||
| 603 | if (verbose) | 673 | if (verbose) |
| 604 | printk(KERN_INFO "%s: called m=%p p=%p\n", | 674 | pr_info("called m=%p p=%p\n", m, p); |
| 605 | __func__, m, p); | ||
| 606 | 675 | ||
| 607 | if (p == SEQ_START_TOKEN) { | 676 | if (p == SEQ_START_TOKEN) { |
| 608 | seq_puts(m, | 677 | seq_puts(m, |
| @@ -627,8 +696,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) | |||
| 627 | static void ddebug_proc_stop(struct seq_file *m, void *p) | 696 | static void ddebug_proc_stop(struct seq_file *m, void *p) |
| 628 | { | 697 | { |
| 629 | if (verbose) | 698 | if (verbose) |
| 630 | printk(KERN_INFO "%s: called m=%p p=%p\n", | 699 | pr_info("called m=%p p=%p\n", m, p); |
| 631 | __func__, m, p); | ||
| 632 | mutex_unlock(&ddebug_lock); | 700 | mutex_unlock(&ddebug_lock); |
| 633 | } | 701 | } |
| 634 | 702 | ||
| @@ -651,7 +719,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file) | |||
| 651 | int err; | 719 | int err; |
| 652 | 720 | ||
| 653 | if (verbose) | 721 | if (verbose) |
| 654 | printk(KERN_INFO "%s: called\n", __func__); | 722 | pr_info("called\n"); |
| 655 | 723 | ||
| 656 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); | 724 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
| 657 | if (iter == NULL) | 725 | if (iter == NULL) |
| @@ -695,7 +763,6 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
| 695 | } | 763 | } |
| 696 | dt->mod_name = new_name; | 764 | dt->mod_name = new_name; |
| 697 | dt->num_ddebugs = n; | 765 | dt->num_ddebugs = n; |
| 698 | dt->num_enabled = 0; | ||
| 699 | dt->ddebugs = tab; | 766 | dt->ddebugs = tab; |
| 700 | 767 | ||
| 701 | mutex_lock(&ddebug_lock); | 768 | mutex_lock(&ddebug_lock); |
| @@ -703,8 +770,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
| 703 | mutex_unlock(&ddebug_lock); | 770 | mutex_unlock(&ddebug_lock); |
| 704 | 771 | ||
| 705 | if (verbose) | 772 | if (verbose) |
| 706 | printk(KERN_INFO "%u debug prints in module %s\n", | 773 | pr_info("%u debug prints in module %s\n", n, dt->mod_name); |
| 707 | n, dt->mod_name); | ||
| 708 | return 0; | 774 | return 0; |
| 709 | } | 775 | } |
| 710 | EXPORT_SYMBOL_GPL(ddebug_add_module); | 776 | EXPORT_SYMBOL_GPL(ddebug_add_module); |
| @@ -726,8 +792,7 @@ int ddebug_remove_module(const char *mod_name) | |||
| 726 | int ret = -ENOENT; | 792 | int ret = -ENOENT; |
| 727 | 793 | ||
| 728 | if (verbose) | 794 | if (verbose) |
| 729 | printk(KERN_INFO "%s: removing module \"%s\"\n", | 795 | pr_info("removing module \"%s\"\n", mod_name); |
| 730 | __func__, mod_name); | ||
| 731 | 796 | ||
| 732 | mutex_lock(&ddebug_lock); | 797 | mutex_lock(&ddebug_lock); |
| 733 | list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { | 798 | list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { |
| @@ -803,8 +868,8 @@ static int __init dynamic_debug_init(void) | |||
| 803 | if (ddebug_setup_string[0] != '\0') { | 868 | if (ddebug_setup_string[0] != '\0') { |
| 804 | ret = ddebug_exec_query(ddebug_setup_string); | 869 | ret = ddebug_exec_query(ddebug_setup_string); |
| 805 | if (ret) | 870 | if (ret) |
| 806 | pr_warning("Invalid ddebug boot param %s", | 871 | pr_warn("Invalid ddebug boot param %s", |
| 807 | ddebug_setup_string); | 872 | ddebug_setup_string); |
| 808 | else | 873 | else |
| 809 | pr_info("ddebug initialized with string %s", | 874 | pr_info("ddebug initialized with string %s", |
| 810 | ddebug_setup_string); | 875 | ddebug_setup_string); |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index f193b7796449..4f7554025e30 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | * setup_fault_attr() is a helper function for various __setup handlers, so it | 14 | * setup_fault_attr() is a helper function for various __setup handlers, so it |
| 15 | * returns 0 on error, because that is what __setup handlers do. | 15 | * returns 0 on error, because that is what __setup handlers do. |
| 16 | */ | 16 | */ |
| 17 | int __init setup_fault_attr(struct fault_attr *attr, char *str) | 17 | int setup_fault_attr(struct fault_attr *attr, char *str) |
| 18 | { | 18 | { |
| 19 | unsigned long probability; | 19 | unsigned long probability; |
| 20 | unsigned long interval; | 20 | unsigned long interval; |
| @@ -36,6 +36,7 @@ int __init setup_fault_attr(struct fault_attr *attr, char *str) | |||
| 36 | 36 | ||
| 37 | return 1; | 37 | return 1; |
| 38 | } | 38 | } |
| 39 | EXPORT_SYMBOL_GPL(setup_fault_attr); | ||
| 39 | 40 | ||
| 40 | static void fail_dump(struct fault_attr *attr) | 41 | static void fail_dump(struct fault_attr *attr) |
| 41 | { | 42 | { |
| @@ -130,6 +131,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size) | |||
| 130 | 131 | ||
| 131 | return true; | 132 | return true; |
| 132 | } | 133 | } |
| 134 | EXPORT_SYMBOL_GPL(should_fail); | ||
| 133 | 135 | ||
| 134 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | 136 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
| 135 | 137 | ||
| @@ -243,5 +245,6 @@ fail: | |||
| 243 | 245 | ||
| 244 | return ERR_PTR(-ENOMEM); | 246 | return ERR_PTR(-ENOMEM); |
| 245 | } | 247 | } |
| 248 | EXPORT_SYMBOL_GPL(fault_create_debugfs_attr); | ||
| 246 | 249 | ||
| 247 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | 250 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
| @@ -767,8 +767,8 @@ EXPORT_SYMBOL(ida_pre_get); | |||
| 767 | * @starting_id: id to start search at | 767 | * @starting_id: id to start search at |
| 768 | * @p_id: pointer to the allocated handle | 768 | * @p_id: pointer to the allocated handle |
| 769 | * | 769 | * |
| 770 | * Allocate new ID above or equal to @ida. It should be called with | 770 | * Allocate new ID above or equal to @starting_id. It should be called |
| 771 | * any required locks. | 771 | * with any required locks. |
| 772 | * | 772 | * |
| 773 | * If memory is required, it will return %-EAGAIN, you should unlock | 773 | * If memory is required, it will return %-EAGAIN, you should unlock |
| 774 | * and go back to the ida_pre_get() call. If the ida is full, it will | 774 | * and go back to the ida_pre_get() call. If the ida is full, it will |
| @@ -944,6 +944,7 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, | |||
| 944 | { | 944 | { |
| 945 | int ret, id; | 945 | int ret, id; |
| 946 | unsigned int max; | 946 | unsigned int max; |
| 947 | unsigned long flags; | ||
| 947 | 948 | ||
| 948 | BUG_ON((int)start < 0); | 949 | BUG_ON((int)start < 0); |
| 949 | BUG_ON((int)end < 0); | 950 | BUG_ON((int)end < 0); |
| @@ -959,7 +960,7 @@ again: | |||
| 959 | if (!ida_pre_get(ida, gfp_mask)) | 960 | if (!ida_pre_get(ida, gfp_mask)) |
| 960 | return -ENOMEM; | 961 | return -ENOMEM; |
| 961 | 962 | ||
| 962 | spin_lock(&simple_ida_lock); | 963 | spin_lock_irqsave(&simple_ida_lock, flags); |
| 963 | ret = ida_get_new_above(ida, start, &id); | 964 | ret = ida_get_new_above(ida, start, &id); |
| 964 | if (!ret) { | 965 | if (!ret) { |
| 965 | if (id > max) { | 966 | if (id > max) { |
| @@ -969,7 +970,7 @@ again: | |||
| 969 | ret = id; | 970 | ret = id; |
| 970 | } | 971 | } |
| 971 | } | 972 | } |
| 972 | spin_unlock(&simple_ida_lock); | 973 | spin_unlock_irqrestore(&simple_ida_lock, flags); |
| 973 | 974 | ||
| 974 | if (unlikely(ret == -EAGAIN)) | 975 | if (unlikely(ret == -EAGAIN)) |
| 975 | goto again; | 976 | goto again; |
| @@ -985,10 +986,12 @@ EXPORT_SYMBOL(ida_simple_get); | |||
| 985 | */ | 986 | */ |
| 986 | void ida_simple_remove(struct ida *ida, unsigned int id) | 987 | void ida_simple_remove(struct ida *ida, unsigned int id) |
| 987 | { | 988 | { |
| 989 | unsigned long flags; | ||
| 990 | |||
| 988 | BUG_ON((int)id < 0); | 991 | BUG_ON((int)id < 0); |
| 989 | spin_lock(&simple_ida_lock); | 992 | spin_lock_irqsave(&simple_ida_lock, flags); |
| 990 | ida_remove(ida, id); | 993 | ida_remove(ida, id); |
| 991 | spin_unlock(&simple_ida_lock); | 994 | spin_unlock_irqrestore(&simple_ida_lock, flags); |
| 992 | } | 995 | } |
| 993 | EXPORT_SYMBOL(ida_simple_remove); | 996 | EXPORT_SYMBOL(ida_simple_remove); |
| 994 | 997 | ||
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 70af0a7f97c0..ad72a03ce5e9 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
| @@ -282,7 +282,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 282 | kobj_bcast_filter, | 282 | kobj_bcast_filter, |
| 283 | kobj); | 283 | kobj); |
| 284 | /* ENOBUFS should be handled in userspace */ | 284 | /* ENOBUFS should be handled in userspace */ |
| 285 | if (retval == -ENOBUFS) | 285 | if (retval == -ENOBUFS || retval == -ESRCH) |
| 286 | retval = 0; | 286 | retval = 0; |
| 287 | } else | 287 | } else |
| 288 | retval = -ENOMEM; | 288 | retval = -ENOMEM; |
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 5e066759f551..7a94c8f14e29 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
| @@ -18,26 +18,40 @@ | |||
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 20 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
| 21 | #include "kstrtox.h" | ||
| 21 | 22 | ||
| 22 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | 23 | const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) |
| 23 | { | 24 | { |
| 24 | unsigned long long acc; | 25 | if (*base == 0) { |
| 25 | int ok; | ||
| 26 | |||
| 27 | if (base == 0) { | ||
| 28 | if (s[0] == '0') { | 26 | if (s[0] == '0') { |
| 29 | if (_tolower(s[1]) == 'x' && isxdigit(s[2])) | 27 | if (_tolower(s[1]) == 'x' && isxdigit(s[2])) |
| 30 | base = 16; | 28 | *base = 16; |
| 31 | else | 29 | else |
| 32 | base = 8; | 30 | *base = 8; |
| 33 | } else | 31 | } else |
| 34 | base = 10; | 32 | *base = 10; |
| 35 | } | 33 | } |
| 36 | if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') | 34 | if (*base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') |
| 37 | s += 2; | 35 | s += 2; |
| 36 | return s; | ||
| 37 | } | ||
| 38 | 38 | ||
| 39 | acc = 0; | 39 | /* |
| 40 | ok = 0; | 40 | * Convert non-negative integer string representation in explicitly given radix |
| 41 | * to an integer. | ||
| 42 | * Return number of characters consumed maybe or-ed with overflow bit. | ||
| 43 | * If overflow occurs, result integer (incorrect) is still returned. | ||
| 44 | * | ||
| 45 | * Don't you dare use this function. | ||
| 46 | */ | ||
| 47 | unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res) | ||
| 48 | { | ||
| 49 | unsigned int rv; | ||
| 50 | int overflow; | ||
| 51 | |||
| 52 | *res = 0; | ||
| 53 | rv = 0; | ||
| 54 | overflow = 0; | ||
| 41 | while (*s) { | 55 | while (*s) { |
| 42 | unsigned int val; | 56 | unsigned int val; |
| 43 | 57 | ||
| @@ -45,23 +59,40 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |||
| 45 | val = *s - '0'; | 59 | val = *s - '0'; |
| 46 | else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') | 60 | else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') |
| 47 | val = _tolower(*s) - 'a' + 10; | 61 | val = _tolower(*s) - 'a' + 10; |
| 48 | else if (*s == '\n' && *(s + 1) == '\0') | ||
| 49 | break; | ||
| 50 | else | 62 | else |
| 51 | return -EINVAL; | 63 | break; |
| 52 | 64 | ||
| 53 | if (val >= base) | 65 | if (val >= base) |
| 54 | return -EINVAL; | 66 | break; |
| 55 | if (acc > div_u64(ULLONG_MAX - val, base)) | 67 | if (*res > div_u64(ULLONG_MAX - val, base)) |
| 56 | return -ERANGE; | 68 | overflow = 1; |
| 57 | acc = acc * base + val; | 69 | *res = *res * base + val; |
| 58 | ok = 1; | 70 | rv++; |
| 59 | |||
| 60 | s++; | 71 | s++; |
| 61 | } | 72 | } |
| 62 | if (!ok) | 73 | if (overflow) |
| 74 | rv |= KSTRTOX_OVERFLOW; | ||
| 75 | return rv; | ||
| 76 | } | ||
| 77 | |||
| 78 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | ||
| 79 | { | ||
| 80 | unsigned long long _res; | ||
| 81 | unsigned int rv; | ||
| 82 | |||
| 83 | s = _parse_integer_fixup_radix(s, &base); | ||
| 84 | rv = _parse_integer(s, base, &_res); | ||
| 85 | if (rv & KSTRTOX_OVERFLOW) | ||
| 86 | return -ERANGE; | ||
| 87 | rv &= ~KSTRTOX_OVERFLOW; | ||
| 88 | if (rv == 0) | ||
| 89 | return -EINVAL; | ||
| 90 | s += rv; | ||
| 91 | if (*s == '\n') | ||
| 92 | s++; | ||
| 93 | if (*s) | ||
| 63 | return -EINVAL; | 94 | return -EINVAL; |
| 64 | *res = acc; | 95 | *res = _res; |
| 65 | return 0; | 96 | return 0; |
| 66 | } | 97 | } |
| 67 | 98 | ||
diff --git a/lib/kstrtox.h b/lib/kstrtox.h new file mode 100644 index 000000000000..f13eeeaf441d --- /dev/null +++ b/lib/kstrtox.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef _LIB_KSTRTOX_H | ||
| 2 | #define _LIB_KSTRTOX_H | ||
| 3 | |||
| 4 | #define KSTRTOX_OVERFLOW (1U << 31) | ||
| 5 | const char *_parse_integer_fixup_radix(const char *s, unsigned int *base); | ||
| 6 | unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res); | ||
| 7 | |||
| 8 | #endif | ||
diff --git a/lib/llist.c b/lib/llist.c index da445724fa1f..700cff77a387 100644 --- a/lib/llist.c +++ b/lib/llist.c | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | * | 3 | * |
| 4 | * The basic atomic operation of this list is cmpxchg on long. On | 4 | * The basic atomic operation of this list is cmpxchg on long. On |
| 5 | * architectures that don't have NMI-safe cmpxchg implementation, the | 5 | * architectures that don't have NMI-safe cmpxchg implementation, the |
| 6 | * list can NOT be used in NMI handler. So code uses the list in NMI | 6 | * list can NOT be used in NMI handlers. So code that uses the list in |
| 7 | * handler should depend on CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG. | 7 | * an NMI handler should depend on CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG. |
| 8 | * | 8 | * |
| 9 | * Copyright 2010,2011 Intel Corp. | 9 | * Copyright 2010,2011 Intel Corp. |
| 10 | * Author: Huang Ying <ying.huang@intel.com> | 10 | * Author: Huang Ying <ying.huang@intel.com> |
| @@ -30,48 +30,28 @@ | |||
| 30 | #include <asm/system.h> | 30 | #include <asm/system.h> |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * llist_add - add a new entry | ||
| 34 | * @new: new entry to be added | ||
| 35 | * @head: the head for your lock-less list | ||
| 36 | */ | ||
| 37 | void llist_add(struct llist_node *new, struct llist_head *head) | ||
| 38 | { | ||
| 39 | struct llist_node *entry, *old_entry; | ||
| 40 | |||
| 41 | #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
| 42 | BUG_ON(in_nmi()); | ||
| 43 | #endif | ||
| 44 | |||
| 45 | entry = head->first; | ||
| 46 | do { | ||
| 47 | old_entry = entry; | ||
| 48 | new->next = entry; | ||
| 49 | cpu_relax(); | ||
| 50 | } while ((entry = cmpxchg(&head->first, old_entry, new)) != old_entry); | ||
| 51 | } | ||
| 52 | EXPORT_SYMBOL_GPL(llist_add); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * llist_add_batch - add several linked entries in batch | 33 | * llist_add_batch - add several linked entries in batch |
| 56 | * @new_first: first entry in batch to be added | 34 | * @new_first: first entry in batch to be added |
| 57 | * @new_last: last entry in batch to be added | 35 | * @new_last: last entry in batch to be added |
| 58 | * @head: the head for your lock-less list | 36 | * @head: the head for your lock-less list |
| 37 | * | ||
| 38 | * Return whether list is empty before adding. | ||
| 59 | */ | 39 | */ |
| 60 | void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, | 40 | bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, |
| 61 | struct llist_head *head) | 41 | struct llist_head *head) |
| 62 | { | 42 | { |
| 63 | struct llist_node *entry, *old_entry; | 43 | struct llist_node *entry, *old_entry; |
| 64 | 44 | ||
| 65 | #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
| 66 | BUG_ON(in_nmi()); | ||
| 67 | #endif | ||
| 68 | |||
| 69 | entry = head->first; | 45 | entry = head->first; |
| 70 | do { | 46 | for (;;) { |
| 71 | old_entry = entry; | 47 | old_entry = entry; |
| 72 | new_last->next = entry; | 48 | new_last->next = entry; |
| 73 | cpu_relax(); | 49 | entry = cmpxchg(&head->first, old_entry, new_first); |
| 74 | } while ((entry = cmpxchg(&head->first, old_entry, new_first)) != old_entry); | 50 | if (entry == old_entry) |
| 51 | break; | ||
| 52 | } | ||
| 53 | |||
| 54 | return old_entry == NULL; | ||
| 75 | } | 55 | } |
| 76 | EXPORT_SYMBOL_GPL(llist_add_batch); | 56 | EXPORT_SYMBOL_GPL(llist_add_batch); |
| 77 | 57 | ||
| @@ -93,37 +73,17 @@ struct llist_node *llist_del_first(struct llist_head *head) | |||
| 93 | { | 73 | { |
| 94 | struct llist_node *entry, *old_entry, *next; | 74 | struct llist_node *entry, *old_entry, *next; |
| 95 | 75 | ||
| 96 | #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
| 97 | BUG_ON(in_nmi()); | ||
| 98 | #endif | ||
| 99 | |||
| 100 | entry = head->first; | 76 | entry = head->first; |
| 101 | do { | 77 | for (;;) { |
| 102 | if (entry == NULL) | 78 | if (entry == NULL) |
| 103 | return NULL; | 79 | return NULL; |
| 104 | old_entry = entry; | 80 | old_entry = entry; |
| 105 | next = entry->next; | 81 | next = entry->next; |
| 106 | cpu_relax(); | 82 | entry = cmpxchg(&head->first, old_entry, next); |
| 107 | } while ((entry = cmpxchg(&head->first, old_entry, next)) != old_entry); | 83 | if (entry == old_entry) |
| 84 | break; | ||
| 85 | } | ||
| 108 | 86 | ||
| 109 | return entry; | 87 | return entry; |
| 110 | } | 88 | } |
| 111 | EXPORT_SYMBOL_GPL(llist_del_first); | 89 | EXPORT_SYMBOL_GPL(llist_del_first); |
| 112 | |||
| 113 | /** | ||
| 114 | * llist_del_all - delete all entries from lock-less list | ||
| 115 | * @head: the head of lock-less list to delete all entries | ||
| 116 | * | ||
| 117 | * If list is empty, return NULL, otherwise, delete all entries and | ||
| 118 | * return the pointer to the first entry. The order of entries | ||
| 119 | * deleted is from the newest to the oldest added one. | ||
| 120 | */ | ||
| 121 | struct llist_node *llist_del_all(struct llist_head *head) | ||
| 122 | { | ||
| 123 | #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
| 124 | BUG_ON(in_nmi()); | ||
| 125 | #endif | ||
| 126 | |||
| 127 | return xchg(&head->first, NULL); | ||
| 128 | } | ||
| 129 | EXPORT_SYMBOL_GPL(llist_del_all); | ||
diff --git a/lib/nlattr.c b/lib/nlattr.c index ac09f2226dc7..a8408b6cacdf 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c | |||
| @@ -20,6 +20,7 @@ static const u16 nla_attr_minlen[NLA_TYPE_MAX+1] = { | |||
| 20 | [NLA_U16] = sizeof(u16), | 20 | [NLA_U16] = sizeof(u16), |
| 21 | [NLA_U32] = sizeof(u32), | 21 | [NLA_U32] = sizeof(u32), |
| 22 | [NLA_U64] = sizeof(u64), | 22 | [NLA_U64] = sizeof(u64), |
| 23 | [NLA_MSECS] = sizeof(u64), | ||
| 23 | [NLA_NESTED] = NLA_HDRLEN, | 24 | [NLA_NESTED] = NLA_HDRLEN, |
| 24 | }; | 25 | }; |
| 25 | 26 | ||
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index 28f2c33c6b53..f8a3f1a829b8 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c | |||
| @@ -10,8 +10,10 @@ | |||
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 11 | #include <linux/debugobjects.h> | 11 | #include <linux/debugobjects.h> |
| 12 | 12 | ||
| 13 | #ifdef CONFIG_HOTPLUG_CPU | ||
| 13 | static LIST_HEAD(percpu_counters); | 14 | static LIST_HEAD(percpu_counters); |
| 14 | static DEFINE_MUTEX(percpu_counters_lock); | 15 | static DEFINE_MUTEX(percpu_counters_lock); |
| 16 | #endif | ||
| 15 | 17 | ||
| 16 | #ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER | 18 | #ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER |
| 17 | 19 | ||
| @@ -59,13 +61,13 @@ void percpu_counter_set(struct percpu_counter *fbc, s64 amount) | |||
| 59 | { | 61 | { |
| 60 | int cpu; | 62 | int cpu; |
| 61 | 63 | ||
| 62 | spin_lock(&fbc->lock); | 64 | raw_spin_lock(&fbc->lock); |
| 63 | for_each_possible_cpu(cpu) { | 65 | for_each_possible_cpu(cpu) { |
| 64 | s32 *pcount = per_cpu_ptr(fbc->counters, cpu); | 66 | s32 *pcount = per_cpu_ptr(fbc->counters, cpu); |
| 65 | *pcount = 0; | 67 | *pcount = 0; |
| 66 | } | 68 | } |
| 67 | fbc->count = amount; | 69 | fbc->count = amount; |
| 68 | spin_unlock(&fbc->lock); | 70 | raw_spin_unlock(&fbc->lock); |
| 69 | } | 71 | } |
| 70 | EXPORT_SYMBOL(percpu_counter_set); | 72 | EXPORT_SYMBOL(percpu_counter_set); |
| 71 | 73 | ||
| @@ -76,10 +78,10 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) | |||
| 76 | preempt_disable(); | 78 | preempt_disable(); |
| 77 | count = __this_cpu_read(*fbc->counters) + amount; | 79 | count = __this_cpu_read(*fbc->counters) + amount; |
| 78 | if (count >= batch || count <= -batch) { | 80 | if (count >= batch || count <= -batch) { |
| 79 | spin_lock(&fbc->lock); | 81 | raw_spin_lock(&fbc->lock); |
| 80 | fbc->count += count; | 82 | fbc->count += count; |
| 81 | __this_cpu_write(*fbc->counters, 0); | 83 | __this_cpu_write(*fbc->counters, 0); |
| 82 | spin_unlock(&fbc->lock); | 84 | raw_spin_unlock(&fbc->lock); |
| 83 | } else { | 85 | } else { |
| 84 | __this_cpu_write(*fbc->counters, count); | 86 | __this_cpu_write(*fbc->counters, count); |
| 85 | } | 87 | } |
| @@ -96,13 +98,13 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc) | |||
| 96 | s64 ret; | 98 | s64 ret; |
| 97 | int cpu; | 99 | int cpu; |
| 98 | 100 | ||
| 99 | spin_lock(&fbc->lock); | 101 | raw_spin_lock(&fbc->lock); |
| 100 | ret = fbc->count; | 102 | ret = fbc->count; |
| 101 | for_each_online_cpu(cpu) { | 103 | for_each_online_cpu(cpu) { |
| 102 | s32 *pcount = per_cpu_ptr(fbc->counters, cpu); | 104 | s32 *pcount = per_cpu_ptr(fbc->counters, cpu); |
| 103 | ret += *pcount; | 105 | ret += *pcount; |
| 104 | } | 106 | } |
| 105 | spin_unlock(&fbc->lock); | 107 | raw_spin_unlock(&fbc->lock); |
| 106 | return ret; | 108 | return ret; |
| 107 | } | 109 | } |
| 108 | EXPORT_SYMBOL(__percpu_counter_sum); | 110 | EXPORT_SYMBOL(__percpu_counter_sum); |
| @@ -110,7 +112,7 @@ EXPORT_SYMBOL(__percpu_counter_sum); | |||
| 110 | int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, | 112 | int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, |
| 111 | struct lock_class_key *key) | 113 | struct lock_class_key *key) |
| 112 | { | 114 | { |
| 113 | spin_lock_init(&fbc->lock); | 115 | raw_spin_lock_init(&fbc->lock); |
| 114 | lockdep_set_class(&fbc->lock, key); | 116 | lockdep_set_class(&fbc->lock, key); |
| 115 | fbc->count = amount; | 117 | fbc->count = amount; |
| 116 | fbc->counters = alloc_percpu(s32); | 118 | fbc->counters = alloc_percpu(s32); |
| @@ -173,11 +175,11 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb, | |||
| 173 | s32 *pcount; | 175 | s32 *pcount; |
| 174 | unsigned long flags; | 176 | unsigned long flags; |
| 175 | 177 | ||
| 176 | spin_lock_irqsave(&fbc->lock, flags); | 178 | raw_spin_lock_irqsave(&fbc->lock, flags); |
| 177 | pcount = per_cpu_ptr(fbc->counters, cpu); | 179 | pcount = per_cpu_ptr(fbc->counters, cpu); |
| 178 | fbc->count += *pcount; | 180 | fbc->count += *pcount; |
| 179 | *pcount = 0; | 181 | *pcount = 0; |
| 180 | spin_unlock_irqrestore(&fbc->lock, flags); | 182 | raw_spin_unlock_irqrestore(&fbc->lock, flags); |
| 181 | } | 183 | } |
| 182 | mutex_unlock(&percpu_counters_lock); | 184 | mutex_unlock(&percpu_counters_lock); |
| 183 | #endif | 185 | #endif |
diff --git a/lib/proportions.c b/lib/proportions.c index d50746a79de2..05df84801b56 100644 --- a/lib/proportions.c +++ b/lib/proportions.c | |||
| @@ -190,7 +190,7 @@ prop_adjust_shift(int *pl_shift, unsigned long *pl_period, int new_shift) | |||
| 190 | 190 | ||
| 191 | int prop_local_init_percpu(struct prop_local_percpu *pl) | 191 | int prop_local_init_percpu(struct prop_local_percpu *pl) |
| 192 | { | 192 | { |
| 193 | spin_lock_init(&pl->lock); | 193 | raw_spin_lock_init(&pl->lock); |
| 194 | pl->shift = 0; | 194 | pl->shift = 0; |
| 195 | pl->period = 0; | 195 | pl->period = 0; |
| 196 | return percpu_counter_init(&pl->events, 0); | 196 | return percpu_counter_init(&pl->events, 0); |
| @@ -226,7 +226,7 @@ void prop_norm_percpu(struct prop_global *pg, struct prop_local_percpu *pl) | |||
| 226 | if (pl->period == global_period) | 226 | if (pl->period == global_period) |
| 227 | return; | 227 | return; |
| 228 | 228 | ||
| 229 | spin_lock_irqsave(&pl->lock, flags); | 229 | raw_spin_lock_irqsave(&pl->lock, flags); |
| 230 | prop_adjust_shift(&pl->shift, &pl->period, pg->shift); | 230 | prop_adjust_shift(&pl->shift, &pl->period, pg->shift); |
| 231 | 231 | ||
| 232 | /* | 232 | /* |
| @@ -247,7 +247,7 @@ void prop_norm_percpu(struct prop_global *pg, struct prop_local_percpu *pl) | |||
| 247 | percpu_counter_set(&pl->events, 0); | 247 | percpu_counter_set(&pl->events, 0); |
| 248 | 248 | ||
| 249 | pl->period = global_period; | 249 | pl->period = global_period; |
| 250 | spin_unlock_irqrestore(&pl->lock, flags); | 250 | raw_spin_unlock_irqrestore(&pl->lock, flags); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /* | 253 | /* |
| @@ -324,7 +324,7 @@ void prop_fraction_percpu(struct prop_descriptor *pd, | |||
| 324 | 324 | ||
| 325 | int prop_local_init_single(struct prop_local_single *pl) | 325 | int prop_local_init_single(struct prop_local_single *pl) |
| 326 | { | 326 | { |
| 327 | spin_lock_init(&pl->lock); | 327 | raw_spin_lock_init(&pl->lock); |
| 328 | pl->shift = 0; | 328 | pl->shift = 0; |
| 329 | pl->period = 0; | 329 | pl->period = 0; |
| 330 | pl->events = 0; | 330 | pl->events = 0; |
| @@ -356,7 +356,7 @@ void prop_norm_single(struct prop_global *pg, struct prop_local_single *pl) | |||
| 356 | if (pl->period == global_period) | 356 | if (pl->period == global_period) |
| 357 | return; | 357 | return; |
| 358 | 358 | ||
| 359 | spin_lock_irqsave(&pl->lock, flags); | 359 | raw_spin_lock_irqsave(&pl->lock, flags); |
| 360 | prop_adjust_shift(&pl->shift, &pl->period, pg->shift); | 360 | prop_adjust_shift(&pl->shift, &pl->period, pg->shift); |
| 361 | /* | 361 | /* |
| 362 | * For each missed period, we half the local counter. | 362 | * For each missed period, we half the local counter. |
| @@ -367,7 +367,7 @@ void prop_norm_single(struct prop_global *pg, struct prop_local_single *pl) | |||
| 367 | else | 367 | else |
| 368 | pl->events = 0; | 368 | pl->events = 0; |
| 369 | pl->period = global_period; | 369 | pl->period = global_period; |
| 370 | spin_unlock_irqrestore(&pl->lock, flags); | 370 | raw_spin_unlock_irqrestore(&pl->lock, flags); |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | /* | 373 | /* |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index a2f9da59c197..d9df7454519c 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
| @@ -576,7 +576,6 @@ int radix_tree_tag_get(struct radix_tree_root *root, | |||
| 576 | { | 576 | { |
| 577 | unsigned int height, shift; | 577 | unsigned int height, shift; |
| 578 | struct radix_tree_node *node; | 578 | struct radix_tree_node *node; |
| 579 | int saw_unset_tag = 0; | ||
| 580 | 579 | ||
| 581 | /* check the root's tag bit */ | 580 | /* check the root's tag bit */ |
| 582 | if (!root_tag_get(root, tag)) | 581 | if (!root_tag_get(root, tag)) |
| @@ -603,15 +602,10 @@ int radix_tree_tag_get(struct radix_tree_root *root, | |||
| 603 | return 0; | 602 | return 0; |
| 604 | 603 | ||
| 605 | offset = (index >> shift) & RADIX_TREE_MAP_MASK; | 604 | offset = (index >> shift) & RADIX_TREE_MAP_MASK; |
| 606 | |||
| 607 | /* | ||
| 608 | * This is just a debug check. Later, we can bale as soon as | ||
| 609 | * we see an unset tag. | ||
| 610 | */ | ||
| 611 | if (!tag_get(node, tag, offset)) | 605 | if (!tag_get(node, tag, offset)) |
| 612 | saw_unset_tag = 1; | 606 | return 0; |
| 613 | if (height == 1) | 607 | if (height == 1) |
| 614 | return !!tag_get(node, tag, offset); | 608 | return 1; |
| 615 | node = rcu_dereference_raw(node->slots[offset]); | 609 | node = rcu_dereference_raw(node->slots[offset]); |
| 616 | shift -= RADIX_TREE_MAP_SHIFT; | 610 | shift -= RADIX_TREE_MAP_SHIFT; |
| 617 | height--; | 611 | height--; |
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index b595f560bee7..8b02f60ffc86 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #include <linux/raid/pq.h> | 19 | #include <linux/raid/pq.h> |
| 20 | #include <linux/module.h> | ||
| 20 | #ifndef __KERNEL__ | 21 | #ifndef __KERNEL__ |
| 21 | #include <sys/mman.h> | 22 | #include <sys/mman.h> |
| 22 | #include <stdio.h> | 23 | #include <stdio.h> |
diff --git a/lib/raid6/int.uc b/lib/raid6/int.uc index d1e276a14fab..5b50f8dfc5d2 100644 --- a/lib/raid6/int.uc +++ b/lib/raid6/int.uc | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | * ----------------------------------------------------------------------- */ | 11 | * ----------------------------------------------------------------------- */ |
| 12 | 12 | ||
| 13 | /* | 13 | /* |
| 14 | * raid6int$#.c | 14 | * int$#.c |
| 15 | * | 15 | * |
| 16 | * $#-way unrolled portable integer math RAID-6 instruction set | 16 | * $#-way unrolled portable integer math RAID-6 instruction set |
| 17 | * | 17 | * |
diff --git a/lib/raid6/mktables.c b/lib/raid6/mktables.c index 3b1500843bba..8a3780902cec 100644 --- a/lib/raid6/mktables.c +++ b/lib/raid6/mktables.c | |||
| @@ -60,6 +60,7 @@ int main(int argc, char *argv[]) | |||
| 60 | uint8_t exptbl[256], invtbl[256]; | 60 | uint8_t exptbl[256], invtbl[256]; |
| 61 | 61 | ||
| 62 | printf("#include <linux/raid/pq.h>\n"); | 62 | printf("#include <linux/raid/pq.h>\n"); |
| 63 | printf("#include <linux/export.h>\n"); | ||
| 63 | 64 | ||
| 64 | /* Compute multiplication table */ | 65 | /* Compute multiplication table */ |
| 65 | printf("\nconst u8 __attribute__((aligned(256)))\n" | 66 | printf("\nconst u8 __attribute__((aligned(256)))\n" |
diff --git a/lib/raid6/recov.c b/lib/raid6/recov.c index 8590d19cf522..fe275d7b6b36 100644 --- a/lib/raid6/recov.c +++ b/lib/raid6/recov.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | * the syndrome.) | 18 | * the syndrome.) |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <linux/export.h> | ||
| 21 | #include <linux/raid/pq.h> | 22 | #include <linux/raid/pq.h> |
| 22 | 23 | ||
| 23 | /* Recover two failed data blocks. */ | 24 | /* Recover two failed data blocks. */ |
diff --git a/lib/ratelimit.c b/lib/ratelimit.c index 027a03f4c56d..c96d500577de 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c | |||
| @@ -39,7 +39,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func) | |||
| 39 | * in addition to the one that will be printed by | 39 | * in addition to the one that will be printed by |
| 40 | * the entity that is holding the lock already: | 40 | * the entity that is holding the lock already: |
| 41 | */ | 41 | */ |
| 42 | if (!spin_trylock_irqsave(&rs->lock, flags)) | 42 | if (!raw_spin_trylock_irqsave(&rs->lock, flags)) |
| 43 | return 0; | 43 | return 0; |
| 44 | 44 | ||
| 45 | if (!rs->begin) | 45 | if (!rs->begin) |
| @@ -60,7 +60,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func) | |||
| 60 | rs->missed++; | 60 | rs->missed++; |
| 61 | ret = 0; | 61 | ret = 0; |
| 62 | } | 62 | } |
| 63 | spin_unlock_irqrestore(&rs->lock, flags); | 63 | raw_spin_unlock_irqrestore(&rs->lock, flags); |
| 64 | 64 | ||
| 65 | return ret; | 65 | return ret; |
| 66 | } | 66 | } |
diff --git a/lib/rwsem-spinlock.c b/lib/rwsem-spinlock.c index ffc9fc7f3b05..f2393c21fe85 100644 --- a/lib/rwsem-spinlock.c +++ b/lib/rwsem-spinlock.c | |||
| @@ -22,9 +22,9 @@ int rwsem_is_locked(struct rw_semaphore *sem) | |||
| 22 | int ret = 1; | 22 | int ret = 1; |
| 23 | unsigned long flags; | 23 | unsigned long flags; |
| 24 | 24 | ||
| 25 | if (spin_trylock_irqsave(&sem->wait_lock, flags)) { | 25 | if (raw_spin_trylock_irqsave(&sem->wait_lock, flags)) { |
| 26 | ret = (sem->activity != 0); | 26 | ret = (sem->activity != 0); |
| 27 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 27 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 28 | } | 28 | } |
| 29 | return ret; | 29 | return ret; |
| 30 | } | 30 | } |
| @@ -44,7 +44,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, | |||
| 44 | lockdep_init_map(&sem->dep_map, name, key, 0); | 44 | lockdep_init_map(&sem->dep_map, name, key, 0); |
| 45 | #endif | 45 | #endif |
| 46 | sem->activity = 0; | 46 | sem->activity = 0; |
| 47 | spin_lock_init(&sem->wait_lock); | 47 | raw_spin_lock_init(&sem->wait_lock); |
| 48 | INIT_LIST_HEAD(&sem->wait_list); | 48 | INIT_LIST_HEAD(&sem->wait_list); |
| 49 | } | 49 | } |
| 50 | EXPORT_SYMBOL(__init_rwsem); | 50 | EXPORT_SYMBOL(__init_rwsem); |
| @@ -145,12 +145,12 @@ void __sched __down_read(struct rw_semaphore *sem) | |||
| 145 | struct task_struct *tsk; | 145 | struct task_struct *tsk; |
| 146 | unsigned long flags; | 146 | unsigned long flags; |
| 147 | 147 | ||
| 148 | spin_lock_irqsave(&sem->wait_lock, flags); | 148 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 149 | 149 | ||
| 150 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { | 150 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { |
| 151 | /* granted */ | 151 | /* granted */ |
| 152 | sem->activity++; | 152 | sem->activity++; |
| 153 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 153 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 154 | goto out; | 154 | goto out; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| @@ -165,7 +165,7 @@ void __sched __down_read(struct rw_semaphore *sem) | |||
| 165 | list_add_tail(&waiter.list, &sem->wait_list); | 165 | list_add_tail(&waiter.list, &sem->wait_list); |
| 166 | 166 | ||
| 167 | /* we don't need to touch the semaphore struct anymore */ | 167 | /* we don't need to touch the semaphore struct anymore */ |
| 168 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 168 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 169 | 169 | ||
| 170 | /* wait to be given the lock */ | 170 | /* wait to be given the lock */ |
| 171 | for (;;) { | 171 | for (;;) { |
| @@ -189,7 +189,7 @@ int __down_read_trylock(struct rw_semaphore *sem) | |||
| 189 | int ret = 0; | 189 | int ret = 0; |
| 190 | 190 | ||
| 191 | 191 | ||
| 192 | spin_lock_irqsave(&sem->wait_lock, flags); | 192 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 193 | 193 | ||
| 194 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { | 194 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { |
| 195 | /* granted */ | 195 | /* granted */ |
| @@ -197,7 +197,7 @@ int __down_read_trylock(struct rw_semaphore *sem) | |||
| 197 | ret = 1; | 197 | ret = 1; |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 200 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 201 | 201 | ||
| 202 | return ret; | 202 | return ret; |
| 203 | } | 203 | } |
| @@ -212,12 +212,12 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass) | |||
| 212 | struct task_struct *tsk; | 212 | struct task_struct *tsk; |
| 213 | unsigned long flags; | 213 | unsigned long flags; |
| 214 | 214 | ||
| 215 | spin_lock_irqsave(&sem->wait_lock, flags); | 215 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 216 | 216 | ||
| 217 | if (sem->activity == 0 && list_empty(&sem->wait_list)) { | 217 | if (sem->activity == 0 && list_empty(&sem->wait_list)) { |
| 218 | /* granted */ | 218 | /* granted */ |
| 219 | sem->activity = -1; | 219 | sem->activity = -1; |
| 220 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 220 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 221 | goto out; | 221 | goto out; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| @@ -232,7 +232,7 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass) | |||
| 232 | list_add_tail(&waiter.list, &sem->wait_list); | 232 | list_add_tail(&waiter.list, &sem->wait_list); |
| 233 | 233 | ||
| 234 | /* we don't need to touch the semaphore struct anymore */ | 234 | /* we don't need to touch the semaphore struct anymore */ |
| 235 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 235 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 236 | 236 | ||
| 237 | /* wait to be given the lock */ | 237 | /* wait to be given the lock */ |
| 238 | for (;;) { | 238 | for (;;) { |
| @@ -260,7 +260,7 @@ int __down_write_trylock(struct rw_semaphore *sem) | |||
| 260 | unsigned long flags; | 260 | unsigned long flags; |
| 261 | int ret = 0; | 261 | int ret = 0; |
| 262 | 262 | ||
| 263 | spin_lock_irqsave(&sem->wait_lock, flags); | 263 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 264 | 264 | ||
| 265 | if (sem->activity == 0 && list_empty(&sem->wait_list)) { | 265 | if (sem->activity == 0 && list_empty(&sem->wait_list)) { |
| 266 | /* granted */ | 266 | /* granted */ |
| @@ -268,7 +268,7 @@ int __down_write_trylock(struct rw_semaphore *sem) | |||
| 268 | ret = 1; | 268 | ret = 1; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 271 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 272 | 272 | ||
| 273 | return ret; | 273 | return ret; |
| 274 | } | 274 | } |
| @@ -280,12 +280,12 @@ void __up_read(struct rw_semaphore *sem) | |||
| 280 | { | 280 | { |
| 281 | unsigned long flags; | 281 | unsigned long flags; |
| 282 | 282 | ||
| 283 | spin_lock_irqsave(&sem->wait_lock, flags); | 283 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 284 | 284 | ||
| 285 | if (--sem->activity == 0 && !list_empty(&sem->wait_list)) | 285 | if (--sem->activity == 0 && !list_empty(&sem->wait_list)) |
| 286 | sem = __rwsem_wake_one_writer(sem); | 286 | sem = __rwsem_wake_one_writer(sem); |
| 287 | 287 | ||
| 288 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 288 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | /* | 291 | /* |
| @@ -295,13 +295,13 @@ void __up_write(struct rw_semaphore *sem) | |||
| 295 | { | 295 | { |
| 296 | unsigned long flags; | 296 | unsigned long flags; |
| 297 | 297 | ||
| 298 | spin_lock_irqsave(&sem->wait_lock, flags); | 298 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 299 | 299 | ||
| 300 | sem->activity = 0; | 300 | sem->activity = 0; |
| 301 | if (!list_empty(&sem->wait_list)) | 301 | if (!list_empty(&sem->wait_list)) |
| 302 | sem = __rwsem_do_wake(sem, 1); | 302 | sem = __rwsem_do_wake(sem, 1); |
| 303 | 303 | ||
| 304 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 304 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | /* | 307 | /* |
| @@ -312,12 +312,12 @@ void __downgrade_write(struct rw_semaphore *sem) | |||
| 312 | { | 312 | { |
| 313 | unsigned long flags; | 313 | unsigned long flags; |
| 314 | 314 | ||
| 315 | spin_lock_irqsave(&sem->wait_lock, flags); | 315 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 316 | 316 | ||
| 317 | sem->activity = 1; | 317 | sem->activity = 1; |
| 318 | if (!list_empty(&sem->wait_list)) | 318 | if (!list_empty(&sem->wait_list)) |
| 319 | sem = __rwsem_do_wake(sem, 0); | 319 | sem = __rwsem_do_wake(sem, 0); |
| 320 | 320 | ||
| 321 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 321 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 322 | } | 322 | } |
| 323 | 323 | ||
diff --git a/lib/rwsem.c b/lib/rwsem.c index aa7c3052261f..410aa1189b13 100644 --- a/lib/rwsem.c +++ b/lib/rwsem.c | |||
| @@ -22,7 +22,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, | |||
| 22 | lockdep_init_map(&sem->dep_map, name, key, 0); | 22 | lockdep_init_map(&sem->dep_map, name, key, 0); |
| 23 | #endif | 23 | #endif |
| 24 | sem->count = RWSEM_UNLOCKED_VALUE; | 24 | sem->count = RWSEM_UNLOCKED_VALUE; |
| 25 | spin_lock_init(&sem->wait_lock); | 25 | raw_spin_lock_init(&sem->wait_lock); |
| 26 | INIT_LIST_HEAD(&sem->wait_list); | 26 | INIT_LIST_HEAD(&sem->wait_list); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -180,7 +180,7 @@ rwsem_down_failed_common(struct rw_semaphore *sem, | |||
| 180 | set_task_state(tsk, TASK_UNINTERRUPTIBLE); | 180 | set_task_state(tsk, TASK_UNINTERRUPTIBLE); |
| 181 | 181 | ||
| 182 | /* set up my own style of waitqueue */ | 182 | /* set up my own style of waitqueue */ |
| 183 | spin_lock_irq(&sem->wait_lock); | 183 | raw_spin_lock_irq(&sem->wait_lock); |
| 184 | waiter.task = tsk; | 184 | waiter.task = tsk; |
| 185 | waiter.flags = flags; | 185 | waiter.flags = flags; |
| 186 | get_task_struct(tsk); | 186 | get_task_struct(tsk); |
| @@ -204,7 +204,7 @@ rwsem_down_failed_common(struct rw_semaphore *sem, | |||
| 204 | adjustment == -RWSEM_ACTIVE_WRITE_BIAS) | 204 | adjustment == -RWSEM_ACTIVE_WRITE_BIAS) |
| 205 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_READ_OWNED); | 205 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_READ_OWNED); |
| 206 | 206 | ||
| 207 | spin_unlock_irq(&sem->wait_lock); | 207 | raw_spin_unlock_irq(&sem->wait_lock); |
| 208 | 208 | ||
| 209 | /* wait to be given the lock */ | 209 | /* wait to be given the lock */ |
| 210 | for (;;) { | 210 | for (;;) { |
| @@ -245,13 +245,13 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem) | |||
| 245 | { | 245 | { |
| 246 | unsigned long flags; | 246 | unsigned long flags; |
| 247 | 247 | ||
| 248 | spin_lock_irqsave(&sem->wait_lock, flags); | 248 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 249 | 249 | ||
| 250 | /* do nothing if list empty */ | 250 | /* do nothing if list empty */ |
| 251 | if (!list_empty(&sem->wait_list)) | 251 | if (!list_empty(&sem->wait_list)) |
| 252 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_ANY); | 252 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_ANY); |
| 253 | 253 | ||
| 254 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 254 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 255 | 255 | ||
| 256 | return sem; | 256 | return sem; |
| 257 | } | 257 | } |
| @@ -265,13 +265,13 @@ struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem) | |||
| 265 | { | 265 | { |
| 266 | unsigned long flags; | 266 | unsigned long flags; |
| 267 | 267 | ||
| 268 | spin_lock_irqsave(&sem->wait_lock, flags); | 268 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 269 | 269 | ||
| 270 | /* do nothing if list empty */ | 270 | /* do nothing if list empty */ |
| 271 | if (!list_empty(&sem->wait_list)) | 271 | if (!list_empty(&sem->wait_list)) |
| 272 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_READ_OWNED); | 272 | sem = __rwsem_do_wake(sem, RWSEM_WAKE_READ_OWNED); |
| 273 | 273 | ||
| 274 | spin_unlock_irqrestore(&sem->wait_lock, flags); | 274 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 275 | 275 | ||
| 276 | return sem; | 276 | return sem; |
| 277 | } | 277 | } |
diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c index 4689cb073da4..503f087382a4 100644 --- a/lib/smp_processor_id.c +++ b/lib/smp_processor_id.c | |||
| @@ -22,7 +22,7 @@ notrace unsigned int debug_smp_processor_id(void) | |||
| 22 | * Kernel threads bound to a single CPU can safely use | 22 | * Kernel threads bound to a single CPU can safely use |
| 23 | * smp_processor_id(): | 23 | * smp_processor_id(): |
| 24 | */ | 24 | */ |
| 25 | if (cpumask_equal(¤t->cpus_allowed, cpumask_of(this_cpu))) | 25 | if (cpumask_equal(tsk_cpus_allowed(current), cpumask_of(this_cpu))) |
| 26 | goto out; | 26 | goto out; |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index 4755b98b6dfb..5f3eacdd6178 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
| @@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name, | |||
| 49 | 49 | ||
| 50 | EXPORT_SYMBOL(__rwlock_init); | 50 | EXPORT_SYMBOL(__rwlock_init); |
| 51 | 51 | ||
| 52 | static void spin_bug(raw_spinlock_t *lock, const char *msg) | 52 | static void spin_dump(raw_spinlock_t *lock, const char *msg) |
| 53 | { | 53 | { |
| 54 | struct task_struct *owner = NULL; | 54 | struct task_struct *owner = NULL; |
| 55 | 55 | ||
| 56 | if (!debug_locks_off()) | ||
| 57 | return; | ||
| 58 | |||
| 59 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) | 56 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) |
| 60 | owner = lock->owner; | 57 | owner = lock->owner; |
| 61 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", | 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", |
| @@ -70,6 +67,14 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg) | |||
| 70 | dump_stack(); | 67 | dump_stack(); |
| 71 | } | 68 | } |
| 72 | 69 | ||
| 70 | static void spin_bug(raw_spinlock_t *lock, const char *msg) | ||
| 71 | { | ||
| 72 | if (!debug_locks_off()) | ||
| 73 | return; | ||
| 74 | |||
| 75 | spin_dump(lock, msg); | ||
| 76 | } | ||
| 77 | |||
| 73 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) | 78 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) |
| 74 | 79 | ||
| 75 | static inline void | 80 | static inline void |
| @@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock) | |||
| 113 | /* lockup suspected: */ | 118 | /* lockup suspected: */ |
| 114 | if (print_once) { | 119 | if (print_once) { |
| 115 | print_once = 0; | 120 | print_once = 0; |
| 116 | printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " | 121 | spin_dump(lock, "lockup"); |
| 117 | "%s/%d, %p\n", | ||
| 118 | raw_smp_processor_id(), current->comm, | ||
| 119 | task_pid_nr(current), lock); | ||
| 120 | dump_stack(); | ||
| 121 | #ifdef CONFIG_SMP | 122 | #ifdef CONFIG_SMP |
| 122 | trigger_all_cpu_backtrace(); | 123 | trigger_all_cpu_backtrace(); |
| 123 | #endif | 124 | #endif |
diff --git a/lib/string.c b/lib/string.c index 01fad9b203e1..dc4a86341f91 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -360,7 +360,6 @@ char *strim(char *s) | |||
| 360 | size_t size; | 360 | size_t size; |
| 361 | char *end; | 361 | char *end; |
| 362 | 362 | ||
| 363 | s = skip_spaces(s); | ||
| 364 | size = strlen(s); | 363 | size = strlen(s); |
| 365 | if (!size) | 364 | if (!size) |
| 366 | return s; | 365 | return s; |
| @@ -370,7 +369,7 @@ char *strim(char *s) | |||
| 370 | end--; | 369 | end--; |
| 371 | *(end + 1) = '\0'; | 370 | *(end + 1) = '\0'; |
| 372 | 371 | ||
| 373 | return s; | 372 | return skip_spaces(s); |
| 374 | } | 373 | } |
| 375 | EXPORT_SYMBOL(strim); | 374 | EXPORT_SYMBOL(strim); |
| 376 | 375 | ||
| @@ -756,3 +755,57 @@ void *memchr(const void *s, int c, size_t n) | |||
| 756 | } | 755 | } |
| 757 | EXPORT_SYMBOL(memchr); | 756 | EXPORT_SYMBOL(memchr); |
| 758 | #endif | 757 | #endif |
| 758 | |||
| 759 | static void *check_bytes8(const u8 *start, u8 value, unsigned int bytes) | ||
| 760 | { | ||
| 761 | while (bytes) { | ||
| 762 | if (*start != value) | ||
| 763 | return (void *)start; | ||
| 764 | start++; | ||
| 765 | bytes--; | ||
| 766 | } | ||
| 767 | return NULL; | ||
| 768 | } | ||
| 769 | |||
| 770 | /** | ||
| 771 | * memchr_inv - Find an unmatching character in an area of memory. | ||
| 772 | * @start: The memory area | ||
| 773 | * @c: Find a character other than c | ||
| 774 | * @bytes: The size of the area. | ||
| 775 | * | ||
| 776 | * returns the address of the first character other than @c, or %NULL | ||
| 777 | * if the whole buffer contains just @c. | ||
| 778 | */ | ||
| 779 | void *memchr_inv(const void *start, int c, size_t bytes) | ||
| 780 | { | ||
| 781 | u8 value = c; | ||
| 782 | u64 value64; | ||
| 783 | unsigned int words, prefix; | ||
| 784 | |||
| 785 | if (bytes <= 16) | ||
| 786 | return check_bytes8(start, value, bytes); | ||
| 787 | |||
| 788 | value64 = value | value << 8 | value << 16 | value << 24; | ||
| 789 | value64 = (value64 & 0xffffffff) | value64 << 32; | ||
| 790 | prefix = 8 - ((unsigned long)start) % 8; | ||
| 791 | |||
| 792 | if (prefix) { | ||
| 793 | u8 *r = check_bytes8(start, value, prefix); | ||
| 794 | if (r) | ||
| 795 | return r; | ||
| 796 | start += prefix; | ||
| 797 | bytes -= prefix; | ||
| 798 | } | ||
| 799 | |||
| 800 | words = bytes / 8; | ||
| 801 | |||
| 802 | while (words) { | ||
| 803 | if (*(u64 *)start != value64) | ||
| 804 | return check_bytes8(start, value, 8); | ||
| 805 | start += 8; | ||
| 806 | words--; | ||
| 807 | } | ||
| 808 | |||
| 809 | return check_bytes8(start, value, bytes % 8); | ||
| 810 | } | ||
| 811 | EXPORT_SYMBOL(memchr_inv); | ||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7222a9c8267..993599e66e5a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -31,17 +31,7 @@ | |||
| 31 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
| 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ | 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ |
| 33 | 33 | ||
| 34 | static unsigned int simple_guess_base(const char *cp) | 34 | #include "kstrtox.h" |
| 35 | { | ||
| 36 | if (cp[0] == '0') { | ||
| 37 | if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) | ||
| 38 | return 16; | ||
| 39 | else | ||
| 40 | return 8; | ||
| 41 | } else { | ||
| 42 | return 10; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | 35 | ||
| 46 | /** | 36 | /** |
| 47 | * simple_strtoull - convert a string to an unsigned long long | 37 | * simple_strtoull - convert a string to an unsigned long long |
| @@ -51,23 +41,14 @@ static unsigned int simple_guess_base(const char *cp) | |||
| 51 | */ | 41 | */ |
| 52 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) | 42 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
| 53 | { | 43 | { |
| 54 | unsigned long long result = 0; | 44 | unsigned long long result; |
| 45 | unsigned int rv; | ||
| 55 | 46 | ||
| 56 | if (!base) | 47 | cp = _parse_integer_fixup_radix(cp, &base); |
| 57 | base = simple_guess_base(cp); | 48 | rv = _parse_integer(cp, base, &result); |
| 49 | /* FIXME */ | ||
| 50 | cp += (rv & ~KSTRTOX_OVERFLOW); | ||
| 58 | 51 | ||
| 59 | if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') | ||
| 60 | cp += 2; | ||
| 61 | |||
| 62 | while (isxdigit(*cp)) { | ||
| 63 | unsigned int value; | ||
| 64 | |||
| 65 | value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; | ||
| 66 | if (value >= base) | ||
| 67 | break; | ||
| 68 | result = result * base + value; | ||
| 69 | cp++; | ||
| 70 | } | ||
| 71 | if (endp) | 52 | if (endp) |
| 72 | *endp = (char *)cp; | 53 | *endp = (char *)cp; |
| 73 | 54 | ||
| @@ -566,7 +547,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr, | |||
| 566 | } | 547 | } |
| 567 | 548 | ||
| 568 | for (i = 0; i < 6; i++) { | 549 | for (i = 0; i < 6; i++) { |
| 569 | p = pack_hex_byte(p, addr[i]); | 550 | p = hex_byte_pack(p, addr[i]); |
| 570 | if (fmt[0] == 'M' && i != 5) | 551 | if (fmt[0] == 'M' && i != 5) |
| 571 | *p++ = separator; | 552 | *p++ = separator; |
| 572 | } | 553 | } |
| @@ -686,13 +667,13 @@ char *ip6_compressed_string(char *p, const char *addr) | |||
| 686 | lo = word & 0xff; | 667 | lo = word & 0xff; |
| 687 | if (hi) { | 668 | if (hi) { |
| 688 | if (hi > 0x0f) | 669 | if (hi > 0x0f) |
| 689 | p = pack_hex_byte(p, hi); | 670 | p = hex_byte_pack(p, hi); |
| 690 | else | 671 | else |
| 691 | *p++ = hex_asc_lo(hi); | 672 | *p++ = hex_asc_lo(hi); |
| 692 | p = pack_hex_byte(p, lo); | 673 | p = hex_byte_pack(p, lo); |
| 693 | } | 674 | } |
| 694 | else if (lo > 0x0f) | 675 | else if (lo > 0x0f) |
| 695 | p = pack_hex_byte(p, lo); | 676 | p = hex_byte_pack(p, lo); |
| 696 | else | 677 | else |
| 697 | *p++ = hex_asc_lo(lo); | 678 | *p++ = hex_asc_lo(lo); |
| 698 | needcolon = true; | 679 | needcolon = true; |
| @@ -714,8 +695,8 @@ char *ip6_string(char *p, const char *addr, const char *fmt) | |||
| 714 | int i; | 695 | int i; |
| 715 | 696 | ||
| 716 | for (i = 0; i < 8; i++) { | 697 | for (i = 0; i < 8; i++) { |
| 717 | p = pack_hex_byte(p, *addr++); | 698 | p = hex_byte_pack(p, *addr++); |
| 718 | p = pack_hex_byte(p, *addr++); | 699 | p = hex_byte_pack(p, *addr++); |
| 719 | if (fmt[0] == 'I' && i != 7) | 700 | if (fmt[0] == 'I' && i != 7) |
| 720 | *p++ = ':'; | 701 | *p++ = ':'; |
| 721 | } | 702 | } |
| @@ -773,7 +754,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
| 773 | } | 754 | } |
| 774 | 755 | ||
| 775 | for (i = 0; i < 16; i++) { | 756 | for (i = 0; i < 16; i++) { |
| 776 | p = pack_hex_byte(p, addr[index[i]]); | 757 | p = hex_byte_pack(p, addr[index[i]]); |
| 777 | switch (i) { | 758 | switch (i) { |
| 778 | case 3: | 759 | case 3: |
| 779 | case 5: | 760 | case 5: |
