aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.6/patches-2.6.27/973-ocf_2.6.27_fix.patch
blob: ecb9bef51315daf64ae57d788d6a67e99c65e3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
--- a/crypto/ocf/random.c
+++ b/crypto/ocf/random.c
@@ -49,6 +49,7 @@
 #include <linux/unistd.h>
 #include <linux/poll.h>
 #include <linux/random.h>
+#include <linux/kthread.h>
 #include <cryptodev.h>
 
 #ifdef CONFIG_OCF_FIPS
@@ -81,7 +82,7 @@ struct random_op {
 
 static int random_proc(void *arg);
 
-static pid_t		randomproc = (pid_t) -1;
+static struct task_struct *random_task;
 static spinlock_t	random_lock;
 
 /*
@@ -141,13 +142,18 @@ crypto_rregister(
 	spin_lock_irqsave(&random_lock, flags);
 	list_add_tail(&rops->random_list, &random_ops);
 	if (!started) {
-		randomproc = kernel_thread(random_proc, NULL, CLONE_FS|CLONE_FILES);
-		if (randomproc < 0) {
-			ret = randomproc;
+		struct task_struct *t;
+
+		t = kthread_create(random_proc, NULL, "ocf-random");
+		if (IS_ERR(t)) {
+			ret = PTR_ERR(t);
 			printk("crypto: crypto_rregister cannot start random thread; "
 					"error %d", ret);
-		} else
+		} else {
+			random_task = t;
+			wake_up_process(t);
 			started = 1;
+		}
 	}
 	spin_unlock_irqrestore(&random_lock, flags);
 
@@ -172,7 +178,7 @@ crypto_runregister_all(u_int32_t driveri
 
 	spin_lock_irqsave(&random_lock, flags);
 	if (list_empty(&random_ops) && started)
-		kill_proc(randomproc, SIGKILL, 1);
+		send_sig(SIGKILL, random_task, 1);
 	spin_unlock_irqrestore(&random_lock, flags);
 	return(0);
 }
@@ -308,7 +314,7 @@ random_proc(void *arg)
 
 bad_alloc:
 	spin_lock_irq(&random_lock);
-	randomproc = (pid_t) -1;
+	random_task = NULL;
 	started = 0;
 	spin_unlock_irq(&random_lock);
 
--- a/crypto/ocf/crypto.c
+++ b/crypto/ocf/crypto.c
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD: src/sys/opencrypto/c
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/version.h>
+#include <linux/kthread.h>
 #include <cryptodev.h>
 
 /*
@@ -255,10 +256,10 @@ module_param(crypto_devallowsoft, int, 0
 MODULE_PARM_DESC(crypto_devallowsoft,
 	   "Enable/disable use of software crypto support");
 
-static pid_t	cryptoproc = (pid_t) -1;
+static struct task_struct *crypto_task;
 static struct	completion cryptoproc_exited;
 static DECLARE_WAIT_QUEUE_HEAD(cryptoproc_wait);
-static pid_t	cryptoretproc = (pid_t) -1;
+static struct task_struct *cryptoret_task;
 static struct	completion cryptoretproc_exited;
 static DECLARE_WAIT_QUEUE_HEAD(cryptoretproc_wait);
 
@@ -1401,7 +1402,7 @@ crypto_proc(void *arg)
 			wait_event_interruptible(cryptoproc_wait,
 					!(list_empty(&crp_q) || crypto_all_qblocked) ||
 					!(list_empty(&crp_kq) || crypto_all_kqblocked) ||
-					cryptoproc == (pid_t) -1);
+					crypto_task == NULL);
 			crp_sleep = 0;
 			if (signal_pending (current)) {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
@@ -1414,7 +1415,7 @@ crypto_proc(void *arg)
 			}
 			CRYPTO_Q_LOCK();
 			dprintk("%s - awake\n", __FUNCTION__);
-			if (cryptoproc == (pid_t) -1)
+			if (crypto_task == NULL)
 				break;
 			cryptostats.cs_intrs++;
 		}
@@ -1470,7 +1471,7 @@ crypto_ret_proc(void *arg)
 			dprintk("%s - sleeping\n", __FUNCTION__);
 			CRYPTO_RETQ_UNLOCK();
 			wait_event_interruptible(cryptoretproc_wait,
-					cryptoretproc == (pid_t) -1 ||
+					cryptoret_task == NULL ||
 					!list_empty(&crp_ret_q) ||
 					!list_empty(&crp_ret_kq));
 			if (signal_pending (current)) {
@@ -1484,7 +1485,7 @@ crypto_ret_proc(void *arg)
 			}
 			CRYPTO_RETQ_LOCK();
 			dprintk("%s - awake\n", __FUNCTION__);
-			if (cryptoretproc == (pid_t) -1) {
+			if (cryptoret_task == NULL) {
 				dprintk("%s - EXITING!\n", __FUNCTION__);
 				break;
 			}
@@ -1597,6 +1598,7 @@ DB_SHOW_COMMAND(kcrypto, db_show_kcrypto
 static int
 crypto_init(void)
 {
+	struct task_struct *t;
 	int error;
 
 	dprintk("%s(0x%x)\n", __FUNCTION__, (int) crypto_init);
@@ -1643,23 +1645,27 @@ crypto_init(void)
 	init_completion(&cryptoproc_exited);
 	init_completion(&cryptoretproc_exited);
 
-	cryptoproc = 0; /* to avoid race condition where proc runs first */
-	cryptoproc = kernel_thread(crypto_proc, NULL, CLONE_FS|CLONE_FILES);
-	if (cryptoproc < 0) {
-		error = cryptoproc;
+	crypto_task = NULL; /* to avoid race condition where proc runs first */
+	t = kthread_create(crypto_proc, NULL, "ocf-crypto");
+	if (IS_ERR(t)) {
+		error = PTR_ERR(t);
 		printk("crypto: crypto_init cannot start crypto thread; error %d",
 			error);
 		goto bad;
 	}
+	wake_up_process(t);
+	crypto_task = t;
 
-	cryptoretproc = 0; /* to avoid race condition where proc runs first */
-	cryptoretproc = kernel_thread(crypto_ret_proc, NULL, CLONE_FS|CLONE_FILES);
-	if (cryptoretproc < 0) {
-		error = cryptoretproc;
+	cryptoret_task = NULL; /* to avoid race condition where proc runs first */
+	t = kthread_create(crypto_ret_proc, NULL, "ocf-cryptoret");
+	if (IS_ERR(t)) {
+		error = PTR_ERR(t);
 		printk("crypto: crypto_init cannot start cryptoret thread; error %d",
 				error);
 		goto bad;
 	}
+	wake_up_process(t);
+	cryptoret_task = t;
 
 	return 0;
 bad:
@@ -1671,7 +1677,7 @@ bad:
 static void
 crypto_exit(void)
 {
-	pid_t p;
+	struct task_struct *t;
 	unsigned long d_flags;
 
 	dprintk("%s()\n", __FUNCTION__);
@@ -1681,18 +1687,18 @@ crypto_exit(void)
 	 */
 
 	CRYPTO_DRIVER_LOCK();
-	p = cryptoproc;
-	cryptoproc = (pid_t) -1;
-	kill_proc(p, SIGTERM, 1);
+	t = crypto_task;
+	crypto_task = NULL;
+	send_sig(SIGTERM, t, 1);
 	wake_up_interruptible(&cryptoproc_wait);
 	CRYPTO_DRIVER_UNLOCK();
 
 	wait_for_completion(&cryptoproc_exited);
 
 	CRYPTO_DRIVER_LOCK();
-	p = cryptoretproc;
-	cryptoretproc = (pid_t) -1;
-	kill_proc(p, SIGTERM, 1);
+	t = cryptoret_task;
+	cryptoret_task = NULL;
+	send_sig(SIGTERM, t, 1);
 	wake_up_interruptible(&cryptoretproc_wait);
 	CRYPTO_DRIVER_UNLOCK();