aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/xor.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /crypto/xor.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'crypto/xor.c')
-rw-r--r--crypto/xor.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/crypto/xor.c b/crypto/xor.c
index 35d6b3adf23..b75182d8ab1 100644
--- a/crypto/xor.c
+++ b/crypto/xor.c
@@ -21,7 +21,6 @@
21#include <linux/gfp.h> 21#include <linux/gfp.h>
22#include <linux/raid/xor.h> 22#include <linux/raid/xor.h>
23#include <linux/jiffies.h> 23#include <linux/jiffies.h>
24#include <linux/preempt.h>
25#include <asm/xor.h> 24#include <asm/xor.h>
26 25
27/* The xor routines to use. */ 26/* The xor routines to use. */
@@ -56,22 +55,20 @@ xor_blocks(unsigned int src_count, unsigned int bytes, void *dest, void **srcs)
56EXPORT_SYMBOL(xor_blocks); 55EXPORT_SYMBOL(xor_blocks);
57 56
58/* Set of all registered templates. */ 57/* Set of all registered templates. */
59static struct xor_block_template *__initdata template_list; 58static struct xor_block_template *template_list;
60 59
61#define BENCH_SIZE (PAGE_SIZE) 60#define BENCH_SIZE (PAGE_SIZE)
62 61
63static void __init 62static void
64do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) 63do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2)
65{ 64{
66 int speed; 65 int speed;
67 unsigned long now, j; 66 unsigned long now;
68 int i, count, max; 67 int i, count, max;
69 68
70 tmpl->next = template_list; 69 tmpl->next = template_list;
71 template_list = tmpl; 70 template_list = tmpl;
72 71
73 preempt_disable();
74
75 /* 72 /*
76 * Count the number of XORs done during a whole jiffy, and use 73 * Count the number of XORs done during a whole jiffy, and use
77 * this to calculate the speed of checksumming. We use a 2-page 74 * this to calculate the speed of checksumming. We use a 2-page
@@ -79,11 +76,9 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2)
79 */ 76 */
80 max = 0; 77 max = 0;
81 for (i = 0; i < 5; i++) { 78 for (i = 0; i < 5; i++) {
82 j = jiffies; 79 now = jiffies;
83 count = 0; 80 count = 0;
84 while ((now = jiffies) == j) 81 while (jiffies == now) {
85 cpu_relax();
86 while (time_before(jiffies, now + 1)) {
87 mb(); /* prevent loop optimzation */ 82 mb(); /* prevent loop optimzation */
88 tmpl->do_2(BENCH_SIZE, b1, b2); 83 tmpl->do_2(BENCH_SIZE, b1, b2);
89 mb(); 84 mb();
@@ -94,8 +89,6 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2)
94 max = count; 89 max = count;
95 } 90 }
96 91
97 preempt_enable();
98
99 speed = max * (HZ * BENCH_SIZE / 1024); 92 speed = max * (HZ * BENCH_SIZE / 1024);
100 tmpl->speed = speed; 93 tmpl->speed = speed;
101 94
@@ -136,9 +129,9 @@ calibrate_xor_blocks(void)
136 129
137 if (fastest) { 130 if (fastest) {
138 printk(KERN_INFO "xor: automatically using best " 131 printk(KERN_INFO "xor: automatically using best "
139 "checksumming function:\n"); 132 "checksumming function: %s\n",
133 fastest->name);
140 xor_speed(fastest); 134 xor_speed(fastest);
141 goto out;
142 } else { 135 } else {
143 printk(KERN_INFO "xor: measuring software checksum speed\n"); 136 printk(KERN_INFO "xor: measuring software checksum speed\n");
144 XOR_TRY_TEMPLATES; 137 XOR_TRY_TEMPLATES;
@@ -153,7 +146,6 @@ calibrate_xor_blocks(void)
153 146
154#undef xor_speed 147#undef xor_speed
155 148
156 out:
157 free_pages((unsigned long)b1, 2); 149 free_pages((unsigned long)b1, 2);
158 150
159 active_template = fastest; 151 active_template = fastest;