aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-07-03 02:57:30 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2008-07-10 08:35:16 -0400
commit4b22f0ddb6564210c9ded7ba25b2a1007733e784 (patch)
treec5e98f3eb875ca30ffcee65ff4ac6968a8b54db9
parent81bef0150074d677d8cbd4e971a8ce6c9746a1fc (diff)
crypto: tcrpyt - Remove unnecessary kmap/kunmap calls
Noticed by Neil Horman: we are doing unnecessary kmap/kunmap calls on kmalloced memory. This patch removes them. For the purposes of testing SG construction, the underlying crypto code already does plenty of kmap/kunmap calls anyway. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/tcrypt.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index ffc1ec6d279e..87f08f9b0904 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -23,7 +23,6 @@
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/crypto.h> 25#include <linux/crypto.h>
26#include <linux/highmem.h>
27#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
28#include <linux/jiffies.h> 27#include <linux/jiffies.h>
29#include <linux/timex.h> 28#include <linux/timex.h>
@@ -31,7 +30,7 @@
31#include "tcrypt.h" 30#include "tcrypt.h"
32 31
33/* 32/*
34 * Need to kmalloc() memory for testing kmap(). 33 * Need to kmalloc() memory for testing.
35 */ 34 */
36#define TVMEMSIZE 16384 35#define TVMEMSIZE 16384
37#define XBUFSIZE 32768 36#define XBUFSIZE 32768
@@ -376,13 +375,12 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
376 goto next_one; 375 goto next_one;
377 } 376 }
378 377
379 q = kmap(sg_page(&sg[0])) + sg[0].offset; 378 q = input;
380 hexdump(q, template[i].rlen); 379 hexdump(q, template[i].rlen);
381 380
382 printk(KERN_INFO "enc/dec: %s\n", 381 printk(KERN_INFO "enc/dec: %s\n",
383 memcmp(q, template[i].result, 382 memcmp(q, template[i].result,
384 template[i].rlen) ? "fail" : "pass"); 383 template[i].rlen) ? "fail" : "pass");
385 kunmap(sg_page(&sg[0]));
386next_one: 384next_one:
387 if (!template[i].key) 385 if (!template[i].key)
388 kfree(key); 386 kfree(key);
@@ -482,7 +480,7 @@ next_one:
482 480
483 for (k = 0, temp = 0; k < template[i].np; k++) { 481 for (k = 0, temp = 0; k < template[i].np; k++) {
484 printk(KERN_INFO "page %u\n", k); 482 printk(KERN_INFO "page %u\n", k);
485 q = kmap(sg_page(&sg[k])) + sg[k].offset; 483 q = &axbuf[IDX[k]];
486 hexdump(q, template[i].tap[k]); 484 hexdump(q, template[i].tap[k]);
487 printk(KERN_INFO "%s\n", 485 printk(KERN_INFO "%s\n",
488 memcmp(q, template[i].result + temp, 486 memcmp(q, template[i].result + temp,
@@ -500,7 +498,6 @@ next_one:
500 } 498 }
501 499
502 temp += template[i].tap[k]; 500 temp += template[i].tap[k];
503 kunmap(sg_page(&sg[k]));
504 } 501 }
505 } 502 }
506 } 503 }
@@ -609,13 +606,12 @@ static void test_cipher(char *algo, int enc,
609 goto out; 606 goto out;
610 } 607 }
611 608
612 q = kmap(sg_page(&sg[0])) + sg[0].offset; 609 q = data;
613 hexdump(q, template[i].rlen); 610 hexdump(q, template[i].rlen);
614 611
615 printk("%s\n", 612 printk("%s\n",
616 memcmp(q, template[i].result, 613 memcmp(q, template[i].result,
617 template[i].rlen) ? "fail" : "pass"); 614 template[i].rlen) ? "fail" : "pass");
618 kunmap(sg_page(&sg[0]));
619 } 615 }
620 kfree(data); 616 kfree(data);
621 } 617 }
@@ -689,7 +685,7 @@ static void test_cipher(char *algo, int enc,
689 temp = 0; 685 temp = 0;
690 for (k = 0; k < template[i].np; k++) { 686 for (k = 0; k < template[i].np; k++) {
691 printk("page %u\n", k); 687 printk("page %u\n", k);
692 q = kmap(sg_page(&sg[k])) + sg[k].offset; 688 q = &xbuf[IDX[k]];
693 hexdump(q, template[i].tap[k]); 689 hexdump(q, template[i].tap[k]);
694 printk("%s\n", 690 printk("%s\n",
695 memcmp(q, template[i].result + temp, 691 memcmp(q, template[i].result + temp,
@@ -704,7 +700,6 @@ static void test_cipher(char *algo, int enc,
704 hexdump(&q[template[i].tap[k]], n); 700 hexdump(&q[template[i].tap[k]], n);
705 } 701 }
706 temp += template[i].tap[k]; 702 temp += template[i].tap[k];
707 kunmap(sg_page(&sg[k]));
708 } 703 }
709 } 704 }
710 } 705 }