]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/crypto/nx/nx-842-powernv.c
Revert "crypto/nx: Rename nx842_powernv_function as icswx function"
[mirror_ubuntu-artful-kernel.git] / drivers / crypto / nx / nx-842-powernv.c
1 /*
2 * Driver for IBM PowerNV 842 compression accelerator
3 *
4 * Copyright (C) 2015 Dan Streetman, IBM Corp
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19 #include "nx-842.h"
20
21 #include <linux/timer.h>
22
23 #include <asm/prom.h>
24 #include <asm/icswx.h>
25 #include <asm/vas.h>
26
27 MODULE_LICENSE("GPL");
28 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
29 MODULE_DESCRIPTION("842 H/W Compression driver for IBM PowerNV processors");
30 MODULE_ALIAS_CRYPTO("842");
31 MODULE_ALIAS_CRYPTO("842-nx");
32
33 #define WORKMEM_ALIGN (CRB_ALIGN)
34 #define CSB_WAIT_MAX (5000) /* ms */
35
36 struct nx842_workmem {
37 /* Below fields must be properly aligned */
38 struct coprocessor_request_block crb; /* CRB_ALIGN align */
39 struct data_descriptor_entry ddl_in[DDL_LEN_MAX]; /* DDE_ALIGN align */
40 struct data_descriptor_entry ddl_out[DDL_LEN_MAX]; /* DDE_ALIGN align */
41 /* Above fields must be properly aligned */
42
43 ktime_t start;
44
45 char padding[WORKMEM_ALIGN]; /* unused, to allow alignment */
46 } __packed __aligned(WORKMEM_ALIGN);
47
48 struct nx842_coproc {
49 unsigned int chip_id;
50 unsigned int ct;
51 unsigned int ci;
52 struct list_head list;
53 };
54
55 /* no cpu hotplug on powernv, so this list never changes after init */
56 static LIST_HEAD(nx842_coprocs);
57 static unsigned int nx842_ct;
58
59 /**
60 * setup_indirect_dde - Setup an indirect DDE
61 *
62 * The DDE is setup with the the DDE count, byte count, and address of
63 * first direct DDE in the list.
64 */
65 static void setup_indirect_dde(struct data_descriptor_entry *dde,
66 struct data_descriptor_entry *ddl,
67 unsigned int dde_count, unsigned int byte_count)
68 {
69 dde->flags = 0;
70 dde->count = dde_count;
71 dde->index = 0;
72 dde->length = cpu_to_be32(byte_count);
73 dde->address = cpu_to_be64(nx842_get_pa(ddl));
74 }
75
76 /**
77 * setup_direct_dde - Setup single DDE from buffer
78 *
79 * The DDE is setup with the buffer and length. The buffer must be properly
80 * aligned. The used length is returned.
81 * Returns:
82 * N Successfully set up DDE with N bytes
83 */
84 static unsigned int setup_direct_dde(struct data_descriptor_entry *dde,
85 unsigned long pa, unsigned int len)
86 {
87 unsigned int l = min_t(unsigned int, len, LEN_ON_PAGE(pa));
88
89 dde->flags = 0;
90 dde->count = 0;
91 dde->index = 0;
92 dde->length = cpu_to_be32(l);
93 dde->address = cpu_to_be64(pa);
94
95 return l;
96 }
97
98 /**
99 * setup_ddl - Setup DDL from buffer
100 *
101 * Returns:
102 * 0 Successfully set up DDL
103 */
104 static int setup_ddl(struct data_descriptor_entry *dde,
105 struct data_descriptor_entry *ddl,
106 unsigned char *buf, unsigned int len,
107 bool in)
108 {
109 unsigned long pa = nx842_get_pa(buf);
110 int i, ret, total_len = len;
111
112 if (!IS_ALIGNED(pa, DDE_BUFFER_ALIGN)) {
113 pr_debug("%s buffer pa 0x%lx not 0x%x-byte aligned\n",
114 in ? "input" : "output", pa, DDE_BUFFER_ALIGN);
115 return -EINVAL;
116 }
117
118 /* only need to check last mult; since buffer must be
119 * DDE_BUFFER_ALIGN aligned, and that is a multiple of
120 * DDE_BUFFER_SIZE_MULT, and pre-last page DDE buffers
121 * are guaranteed a multiple of DDE_BUFFER_SIZE_MULT.
122 */
123 if (len % DDE_BUFFER_LAST_MULT) {
124 pr_debug("%s buffer len 0x%x not a multiple of 0x%x\n",
125 in ? "input" : "output", len, DDE_BUFFER_LAST_MULT);
126 if (in)
127 return -EINVAL;
128 len = round_down(len, DDE_BUFFER_LAST_MULT);
129 }
130
131 /* use a single direct DDE */
132 if (len <= LEN_ON_PAGE(pa)) {
133 ret = setup_direct_dde(dde, pa, len);
134 WARN_ON(ret < len);
135 return 0;
136 }
137
138 /* use the DDL */
139 for (i = 0; i < DDL_LEN_MAX && len > 0; i++) {
140 ret = setup_direct_dde(&ddl[i], pa, len);
141 buf += ret;
142 len -= ret;
143 pa = nx842_get_pa(buf);
144 }
145
146 if (len > 0) {
147 pr_debug("0x%x total %s bytes 0x%x too many for DDL.\n",
148 total_len, in ? "input" : "output", len);
149 if (in)
150 return -EMSGSIZE;
151 total_len -= len;
152 }
153 setup_indirect_dde(dde, ddl, i, total_len);
154
155 return 0;
156 }
157
158 #define CSB_ERR(csb, msg, ...) \
159 pr_err("ERROR: " msg " : %02x %02x %02x %02x %08x\n", \
160 ##__VA_ARGS__, (csb)->flags, \
161 (csb)->cs, (csb)->cc, (csb)->ce, \
162 be32_to_cpu((csb)->count))
163
164 #define CSB_ERR_ADDR(csb, msg, ...) \
165 CSB_ERR(csb, msg " at %lx", ##__VA_ARGS__, \
166 (unsigned long)be64_to_cpu((csb)->address))
167
168 /**
169 * wait_for_csb
170 */
171 static int wait_for_csb(struct nx842_workmem *wmem,
172 struct coprocessor_status_block *csb)
173 {
174 ktime_t start = wmem->start, now = ktime_get();
175 ktime_t timeout = ktime_add_ms(start, CSB_WAIT_MAX);
176
177 while (!(ACCESS_ONCE(csb->flags) & CSB_V)) {
178 cpu_relax();
179 now = ktime_get();
180 if (ktime_after(now, timeout))
181 break;
182 }
183
184 /* hw has updated csb and output buffer */
185 barrier();
186
187 /* check CSB flags */
188 if (!(csb->flags & CSB_V)) {
189 CSB_ERR(csb, "CSB still not valid after %ld us, giving up",
190 (long)ktime_us_delta(now, start));
191 return -ETIMEDOUT;
192 }
193 if (csb->flags & CSB_F) {
194 CSB_ERR(csb, "Invalid CSB format");
195 return -EPROTO;
196 }
197 if (csb->flags & CSB_CH) {
198 CSB_ERR(csb, "Invalid CSB chaining state");
199 return -EPROTO;
200 }
201
202 /* verify CSB completion sequence is 0 */
203 if (csb->cs) {
204 CSB_ERR(csb, "Invalid CSB completion sequence");
205 return -EPROTO;
206 }
207
208 /* check CSB Completion Code */
209 switch (csb->cc) {
210 /* no error */
211 case CSB_CC_SUCCESS:
212 break;
213 case CSB_CC_TPBC_GT_SPBC:
214 /* not an error, but the compressed data is
215 * larger than the uncompressed data :(
216 */
217 break;
218
219 /* input data errors */
220 case CSB_CC_OPERAND_OVERLAP:
221 /* input and output buffers overlap */
222 CSB_ERR(csb, "Operand Overlap error");
223 return -EINVAL;
224 case CSB_CC_INVALID_OPERAND:
225 CSB_ERR(csb, "Invalid operand");
226 return -EINVAL;
227 case CSB_CC_NOSPC:
228 /* output buffer too small */
229 return -ENOSPC;
230 case CSB_CC_ABORT:
231 CSB_ERR(csb, "Function aborted");
232 return -EINTR;
233 case CSB_CC_CRC_MISMATCH:
234 CSB_ERR(csb, "CRC mismatch");
235 return -EINVAL;
236 case CSB_CC_TEMPL_INVALID:
237 CSB_ERR(csb, "Compressed data template invalid");
238 return -EINVAL;
239 case CSB_CC_TEMPL_OVERFLOW:
240 CSB_ERR(csb, "Compressed data template shows data past end");
241 return -EINVAL;
242
243 /* these should not happen */
244 case CSB_CC_INVALID_ALIGN:
245 /* setup_ddl should have detected this */
246 CSB_ERR_ADDR(csb, "Invalid alignment");
247 return -EINVAL;
248 case CSB_CC_DATA_LENGTH:
249 /* setup_ddl should have detected this */
250 CSB_ERR(csb, "Invalid data length");
251 return -EINVAL;
252 case CSB_CC_WR_TRANSLATION:
253 case CSB_CC_TRANSLATION:
254 case CSB_CC_TRANSLATION_DUP1:
255 case CSB_CC_TRANSLATION_DUP2:
256 case CSB_CC_TRANSLATION_DUP3:
257 case CSB_CC_TRANSLATION_DUP4:
258 case CSB_CC_TRANSLATION_DUP5:
259 case CSB_CC_TRANSLATION_DUP6:
260 /* should not happen, we use physical addrs */
261 CSB_ERR_ADDR(csb, "Translation error");
262 return -EPROTO;
263 case CSB_CC_WR_PROTECTION:
264 case CSB_CC_PROTECTION:
265 case CSB_CC_PROTECTION_DUP1:
266 case CSB_CC_PROTECTION_DUP2:
267 case CSB_CC_PROTECTION_DUP3:
268 case CSB_CC_PROTECTION_DUP4:
269 case CSB_CC_PROTECTION_DUP5:
270 case CSB_CC_PROTECTION_DUP6:
271 /* should not happen, we use physical addrs */
272 CSB_ERR_ADDR(csb, "Protection error");
273 return -EPROTO;
274 case CSB_CC_PRIVILEGE:
275 /* shouldn't happen, we're in HYP mode */
276 CSB_ERR(csb, "Insufficient Privilege error");
277 return -EPROTO;
278 case CSB_CC_EXCESSIVE_DDE:
279 /* shouldn't happen, setup_ddl doesn't use many dde's */
280 CSB_ERR(csb, "Too many DDEs in DDL");
281 return -EINVAL;
282 case CSB_CC_TRANSPORT:
283 /* shouldn't happen, we setup CRB correctly */
284 CSB_ERR(csb, "Invalid CRB");
285 return -EINVAL;
286 case CSB_CC_SEGMENTED_DDL:
287 /* shouldn't happen, setup_ddl creates DDL right */
288 CSB_ERR(csb, "Segmented DDL error");
289 return -EINVAL;
290 case CSB_CC_DDE_OVERFLOW:
291 /* shouldn't happen, setup_ddl creates DDL right */
292 CSB_ERR(csb, "DDE overflow error");
293 return -EINVAL;
294 case CSB_CC_SESSION:
295 /* should not happen with ICSWX */
296 CSB_ERR(csb, "Session violation error");
297 return -EPROTO;
298 case CSB_CC_CHAIN:
299 /* should not happen, we don't use chained CRBs */
300 CSB_ERR(csb, "Chained CRB error");
301 return -EPROTO;
302 case CSB_CC_SEQUENCE:
303 /* should not happen, we don't use chained CRBs */
304 CSB_ERR(csb, "CRB seqeunce number error");
305 return -EPROTO;
306 case CSB_CC_UNKNOWN_CODE:
307 CSB_ERR(csb, "Unknown subfunction code");
308 return -EPROTO;
309
310 /* hardware errors */
311 case CSB_CC_RD_EXTERNAL:
312 case CSB_CC_RD_EXTERNAL_DUP1:
313 case CSB_CC_RD_EXTERNAL_DUP2:
314 case CSB_CC_RD_EXTERNAL_DUP3:
315 CSB_ERR_ADDR(csb, "Read error outside coprocessor");
316 return -EPROTO;
317 case CSB_CC_WR_EXTERNAL:
318 CSB_ERR_ADDR(csb, "Write error outside coprocessor");
319 return -EPROTO;
320 case CSB_CC_INTERNAL:
321 CSB_ERR(csb, "Internal error in coprocessor");
322 return -EPROTO;
323 case CSB_CC_PROVISION:
324 CSB_ERR(csb, "Storage provision error");
325 return -EPROTO;
326 case CSB_CC_HW:
327 CSB_ERR(csb, "Correctable hardware error");
328 return -EPROTO;
329
330 default:
331 CSB_ERR(csb, "Invalid CC %d", csb->cc);
332 return -EPROTO;
333 }
334
335 /* check Completion Extension state */
336 if (csb->ce & CSB_CE_TERMINATION) {
337 CSB_ERR(csb, "CSB request was terminated");
338 return -EPROTO;
339 }
340 if (csb->ce & CSB_CE_INCOMPLETE) {
341 CSB_ERR(csb, "CSB request not complete");
342 return -EPROTO;
343 }
344 if (!(csb->ce & CSB_CE_TPBC)) {
345 CSB_ERR(csb, "TPBC not provided, unknown target length");
346 return -EPROTO;
347 }
348
349 /* successful completion */
350 pr_debug_ratelimited("Processed %u bytes in %lu us\n",
351 be32_to_cpu(csb->count),
352 (unsigned long)ktime_us_delta(now, start));
353
354 return 0;
355 }
356
357 /**
358 * nx842_powernv_function - compress/decompress data using the 842 algorithm
359 *
360 * (De)compression provided by the NX842 coprocessor on IBM PowerNV systems.
361 * This compresses or decompresses the provided input buffer into the provided
362 * output buffer.
363 *
364 * Upon return from this function @outlen contains the length of the
365 * output data. If there is an error then @outlen will be 0 and an
366 * error will be specified by the return code from this function.
367 *
368 * The @workmem buffer should only be used by one function call at a time.
369 *
370 * @in: input buffer pointer
371 * @inlen: input buffer size
372 * @out: output buffer pointer
373 * @outlenp: output buffer size pointer
374 * @workmem: working memory buffer pointer, size determined by
375 * nx842_powernv_driver.workmem_size
376 * @fc: function code, see CCW Function Codes in nx-842.h
377 *
378 * Returns:
379 * 0 Success, output of length @outlenp stored in the buffer at @out
380 * -ENODEV Hardware unavailable
381 * -ENOSPC Output buffer is to small
382 * -EMSGSIZE Input buffer too large
383 * -EINVAL buffer constraints do not fix nx842_constraints
384 * -EPROTO hardware error during operation
385 * -ETIMEDOUT hardware did not complete operation in reasonable time
386 * -EINTR operation was aborted
387 */
388 static int nx842_powernv_function(const unsigned char *in, unsigned int inlen,
389 unsigned char *out, unsigned int *outlenp,
390 void *workmem, int fc)
391 {
392 struct coprocessor_request_block *crb;
393 struct coprocessor_status_block *csb;
394 struct nx842_workmem *wmem;
395 int ret;
396 u64 csb_addr;
397 u32 ccw;
398 unsigned int outlen = *outlenp;
399
400 wmem = PTR_ALIGN(workmem, WORKMEM_ALIGN);
401
402 *outlenp = 0;
403
404 /* shoudn't happen, we don't load without a coproc */
405 if (!nx842_ct) {
406 pr_err_ratelimited("coprocessor CT is 0");
407 return -ENODEV;
408 }
409
410 crb = &wmem->crb;
411 csb = &crb->csb;
412
413 /* Clear any previous values */
414 memset(crb, 0, sizeof(*crb));
415
416 /* set up DDLs */
417 ret = setup_ddl(&crb->source, wmem->ddl_in,
418 (unsigned char *)in, inlen, true);
419 if (ret)
420 return ret;
421 ret = setup_ddl(&crb->target, wmem->ddl_out,
422 out, outlen, false);
423 if (ret)
424 return ret;
425
426 /* set up CCW */
427 ccw = 0;
428 ccw = SET_FIELD(CCW_CT, ccw, nx842_ct);
429 ccw = SET_FIELD(CCW_CI_842, ccw, 0); /* use 0 for hw auto-selection */
430 ccw = SET_FIELD(CCW_FC_842, ccw, fc);
431
432 /* set up CRB's CSB addr */
433 csb_addr = nx842_get_pa(csb) & CRB_CSB_ADDRESS;
434 csb_addr |= CRB_CSB_AT; /* Addrs are phys */
435 crb->csb_addr = cpu_to_be64(csb_addr);
436
437 wmem->start = ktime_get();
438
439 /* do ICSWX */
440 ret = icswx(cpu_to_be32(ccw), crb);
441
442 pr_debug_ratelimited("icswx CR %x ccw %x crb->ccw %x\n", ret,
443 (unsigned int)ccw,
444 (unsigned int)be32_to_cpu(crb->ccw));
445
446 /*
447 * NX842 coprocessor sets 3rd bit in CR register with XER[S0].
448 * XER[S0] is the integer summary overflow bit which is nothing
449 * to do NX. Since this bit can be set with other return values,
450 * mask this bit.
451 */
452 ret &= ~ICSWX_XERS0;
453
454 switch (ret) {
455 case ICSWX_INITIATED:
456 ret = wait_for_csb(wmem, csb);
457 break;
458 case ICSWX_BUSY:
459 pr_debug_ratelimited("842 Coprocessor busy\n");
460 ret = -EBUSY;
461 break;
462 case ICSWX_REJECTED:
463 pr_err_ratelimited("ICSWX rejected\n");
464 ret = -EPROTO;
465 break;
466 }
467
468 if (!ret)
469 *outlenp = be32_to_cpu(csb->count);
470
471 return ret;
472 }
473
474 /**
475 * nx842_powernv_compress - Compress data using the 842 algorithm
476 *
477 * Compression provided by the NX842 coprocessor on IBM PowerNV systems.
478 * The input buffer is compressed and the result is stored in the
479 * provided output buffer.
480 *
481 * Upon return from this function @outlen contains the length of the
482 * compressed data. If there is an error then @outlen will be 0 and an
483 * error will be specified by the return code from this function.
484 *
485 * @in: input buffer pointer
486 * @inlen: input buffer size
487 * @out: output buffer pointer
488 * @outlenp: output buffer size pointer
489 * @workmem: working memory buffer pointer, size determined by
490 * nx842_powernv_driver.workmem_size
491 *
492 * Returns: see @nx842_powernv_function()
493 */
494 static int nx842_powernv_compress(const unsigned char *in, unsigned int inlen,
495 unsigned char *out, unsigned int *outlenp,
496 void *wmem)
497 {
498 return nx842_powernv_function(in, inlen, out, outlenp,
499 wmem, CCW_FC_842_COMP_CRC);
500 }
501
502 /**
503 * nx842_powernv_decompress - Decompress data using the 842 algorithm
504 *
505 * Decompression provided by the NX842 coprocessor on IBM PowerNV systems.
506 * The input buffer is decompressed and the result is stored in the
507 * provided output buffer.
508 *
509 * Upon return from this function @outlen contains the length of the
510 * decompressed data. If there is an error then @outlen will be 0 and an
511 * error will be specified by the return code from this function.
512 *
513 * @in: input buffer pointer
514 * @inlen: input buffer size
515 * @out: output buffer pointer
516 * @outlenp: output buffer size pointer
517 * @workmem: working memory buffer pointer, size determined by
518 * nx842_powernv_driver.workmem_size
519 *
520 * Returns: see @nx842_powernv_function()
521 */
522 static int nx842_powernv_decompress(const unsigned char *in, unsigned int inlen,
523 unsigned char *out, unsigned int *outlenp,
524 void *wmem)
525 {
526 return nx842_powernv_function(in, inlen, out, outlenp,
527 wmem, CCW_FC_842_DECOMP_CRC);
528 }
529
530 static int __init nx842_powernv_probe(struct device_node *dn)
531 {
532 struct nx842_coproc *coproc;
533 unsigned int ct, ci;
534 int chip_id;
535
536 chip_id = of_get_ibm_chip_id(dn);
537 if (chip_id < 0) {
538 pr_err("ibm,chip-id missing\n");
539 return -EINVAL;
540 }
541
542 if (of_property_read_u32(dn, "ibm,842-coprocessor-type", &ct)) {
543 pr_err("ibm,842-coprocessor-type missing\n");
544 return -EINVAL;
545 }
546
547 if (of_property_read_u32(dn, "ibm,842-coprocessor-instance", &ci)) {
548 pr_err("ibm,842-coprocessor-instance missing\n");
549 return -EINVAL;
550 }
551
552 coproc = kmalloc(sizeof(*coproc), GFP_KERNEL);
553 if (!coproc)
554 return -ENOMEM;
555
556 coproc->chip_id = chip_id;
557 coproc->ct = ct;
558 coproc->ci = ci;
559 INIT_LIST_HEAD(&coproc->list);
560 list_add(&coproc->list, &nx842_coprocs);
561
562 pr_info("coprocessor found on chip %d, CT %d CI %d\n", chip_id, ct, ci);
563
564 if (!nx842_ct)
565 nx842_ct = ct;
566 else if (nx842_ct != ct)
567 pr_err("NX842 chip %d, CT %d != first found CT %d\n",
568 chip_id, ct, nx842_ct);
569
570 return 0;
571 }
572
573 static struct nx842_constraints nx842_powernv_constraints = {
574 .alignment = DDE_BUFFER_ALIGN,
575 .multiple = DDE_BUFFER_LAST_MULT,
576 .minimum = DDE_BUFFER_LAST_MULT,
577 .maximum = (DDL_LEN_MAX - 1) * PAGE_SIZE,
578 };
579
580 static struct nx842_driver nx842_powernv_driver = {
581 .name = KBUILD_MODNAME,
582 .owner = THIS_MODULE,
583 .workmem_size = sizeof(struct nx842_workmem),
584 .constraints = &nx842_powernv_constraints,
585 .compress = nx842_powernv_compress,
586 .decompress = nx842_powernv_decompress,
587 };
588
589 static int nx842_powernv_crypto_init(struct crypto_tfm *tfm)
590 {
591 return nx842_crypto_init(tfm, &nx842_powernv_driver);
592 }
593
594 static struct crypto_alg nx842_powernv_alg = {
595 .cra_name = "842",
596 .cra_driver_name = "842-nx",
597 .cra_priority = 300,
598 .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
599 .cra_ctxsize = sizeof(struct nx842_crypto_ctx),
600 .cra_module = THIS_MODULE,
601 .cra_init = nx842_powernv_crypto_init,
602 .cra_exit = nx842_crypto_exit,
603 .cra_u = { .compress = {
604 .coa_compress = nx842_crypto_compress,
605 .coa_decompress = nx842_crypto_decompress } }
606 };
607
608 static __init int nx842_powernv_init(void)
609 {
610 struct device_node *dn;
611 int ret;
612
613 /* verify workmem size/align restrictions */
614 BUILD_BUG_ON(WORKMEM_ALIGN % CRB_ALIGN);
615 BUILD_BUG_ON(CRB_ALIGN % DDE_ALIGN);
616 BUILD_BUG_ON(CRB_SIZE % DDE_ALIGN);
617 /* verify buffer size/align restrictions */
618 BUILD_BUG_ON(PAGE_SIZE % DDE_BUFFER_ALIGN);
619 BUILD_BUG_ON(DDE_BUFFER_ALIGN % DDE_BUFFER_SIZE_MULT);
620 BUILD_BUG_ON(DDE_BUFFER_SIZE_MULT % DDE_BUFFER_LAST_MULT);
621
622 for_each_compatible_node(dn, NULL, "ibm,power-nx")
623 nx842_powernv_probe(dn);
624
625 if (!nx842_ct)
626 return -ENODEV;
627
628 ret = crypto_register_alg(&nx842_powernv_alg);
629 if (ret) {
630 struct nx842_coproc *coproc, *n;
631
632 list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
633 list_del(&coproc->list);
634 kfree(coproc);
635 }
636
637 return ret;
638 }
639
640 return 0;
641 }
642 module_init(nx842_powernv_init);
643
644 static void __exit nx842_powernv_exit(void)
645 {
646 struct nx842_coproc *coproc, *n;
647
648 crypto_unregister_alg(&nx842_powernv_alg);
649
650 list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
651 list_del(&coproc->list);
652 kfree(coproc);
653 }
654 }
655 module_exit(nx842_powernv_exit);