aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Steiner <steiner@sgi.com>2009-12-15 19:48:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 10:20:15 -0500
commit33f3648342dc40f8bd6383a5a1a91c22e06f6b77 (patch)
tree27efd17d8ef0fcc0d5c42a8cc4b0d87accae8266
parentb8229bedd1f39799dc83d5c0dad0bd9cd3e5f44c (diff)
gru: add test for gru_copy_gpa
Improve existing driver self-tests. Add a new debugging test to the SGI GRU driver for verifying the global GRU copy function. Signed-off-by: Jack Steiner <steiner@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/misc/sgi-gru/grukservices.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
index e0d4b53d1fc2..24ec109e61cc 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -1004,6 +1004,7 @@ static int quicktest2(unsigned long arg)
1004 int ret = 0; 1004 int ret = 0;
1005 unsigned long *buf; 1005 unsigned long *buf;
1006 void *cb0, *cb; 1006 void *cb0, *cb;
1007 struct gru_control_block_status *gen;
1007 int i, k, istatus, bytes; 1008 int i, k, istatus, bytes;
1008 1009
1009 bytes = numcb * 4 * 8; 1010 bytes = numcb * 4 * 8;
@@ -1023,20 +1024,30 @@ static int quicktest2(unsigned long arg)
1023 XTYPE_DW, 4, 1, IMA_INTERRUPT); 1024 XTYPE_DW, 4, 1, IMA_INTERRUPT);
1024 1025
1025 ret = 0; 1026 ret = 0;
1026 for (k = 0; k < numcb; k++) { 1027 k = numcb;
1028 do {
1027 gru_wait_async_cbr(han); 1029 gru_wait_async_cbr(han);
1028 for (i = 0; i < numcb; i++) { 1030 for (i = 0; i < numcb; i++) {
1029 cb = cb0 + i * GRU_HANDLE_STRIDE; 1031 cb = cb0 + i * GRU_HANDLE_STRIDE;
1030 istatus = gru_check_status(cb); 1032 istatus = gru_check_status(cb);
1031 if (istatus == CBS_ACTIVE) 1033 if (istatus != CBS_ACTIVE && istatus != CBS_CALL_OS)
1032 continue; 1034 break;
1033 if (istatus == CBS_EXCEPTION)
1034 ret = -EFAULT;
1035 else if (buf[i] || buf[i + 1] || buf[i + 2] ||
1036 buf[i + 3])
1037 ret = -EIO;
1038 } 1035 }
1039 } 1036 if (i == numcb)
1037 continue;
1038 if (istatus != CBS_IDLE) {
1039 printk(KERN_DEBUG "GRU:%d quicktest2: cb %d, exception\n", smp_processor_id(), i);
1040 ret = -EFAULT;
1041 } else if (buf[4 * i] || buf[4 * i + 1] || buf[4 * i + 2] ||
1042 buf[4 * i + 3]) {
1043 printk(KERN_DEBUG "GRU:%d quicktest2:cb %d, buf 0x%lx, 0x%lx, 0x%lx, 0x%lx\n",
1044 smp_processor_id(), i, buf[4 * i], buf[4 * i + 1], buf[4 * i + 2], buf[4 * i + 3]);
1045 ret = -EIO;
1046 }
1047 k--;
1048 gen = cb;
1049 gen->istatus = CBS_CALL_OS; /* don't handle this CBR again */
1050 } while (k);
1040 BUG_ON(cmp.done); 1051 BUG_ON(cmp.done);
1041 1052
1042 gru_unlock_async_resource(han); 1053 gru_unlock_async_resource(han);
@@ -1046,6 +1057,22 @@ done:
1046 return ret; 1057 return ret;
1047} 1058}
1048 1059
1060#define BUFSIZE 200
1061static int quicktest3(unsigned long arg)
1062{
1063 char buf1[BUFSIZE], buf2[BUFSIZE];
1064 int ret = 0;
1065
1066 memset(buf2, 0, sizeof(buf2));
1067 memset(buf1, get_cycles() & 255, sizeof(buf1));
1068 gru_copy_gpa(uv_gpa(buf2), uv_gpa(buf1), BUFSIZE);
1069 if (memcmp(buf1, buf2, BUFSIZE)) {
1070 printk(KERN_DEBUG "GRU quicktest3 error\n");
1071 ret = -EIO;
1072 }
1073 return ret;
1074}
1075
1049/* 1076/*
1050 * Debugging only. User hook for various kernel tests 1077 * Debugging only. User hook for various kernel tests
1051 * of driver & gru. 1078 * of driver & gru.
@@ -1064,6 +1091,9 @@ int gru_ktest(unsigned long arg)
1064 case 2: 1091 case 2:
1065 ret = quicktest2(arg); 1092 ret = quicktest2(arg);
1066 break; 1093 break;
1094 case 3:
1095 ret = quicktest3(arg);
1096 break;
1067 case 99: 1097 case 99:
1068 ret = gru_free_kernel_contexts(); 1098 ret = gru_free_kernel_contexts();
1069 break; 1099 break;