]> xenbits.xensource.com Git - xentesttools/bootstrap.git/commitdiff
Add test-case to do wb->wc and vice-versa forever..
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 4 Nov 2011 17:56:56 +0000 (13:56 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 4 May 2012 20:03:22 +0000 (16:03 -0400)
root_image/drivers/Makefile
root_image/drivers/wb_to_wc/Makefile [new file with mode: 0644]
root_image/drivers/wb_to_wc/wb_to_wc.c [new file with mode: 0644]

index 3c1b76a41e298bb7e6538dc5675c93c4697e8291..6dbdb758c1cace35b5d62f9a4ec3370e7a82fad5 100644 (file)
@@ -1,4 +1,5 @@
 obj-m += dump/
+obj-m += wb_to_wc/
 
 .PHONY:        distclean
 distclean:     clean
diff --git a/root_image/drivers/wb_to_wc/Makefile b/root_image/drivers/wb_to_wc/Makefile
new file mode 100644 (file)
index 0000000..cc280a6
--- /dev/null
@@ -0,0 +1,37 @@
+# Comment/uncomment the following line to disable/enable debugging
+#DEBUG = y
+
+# Add your debugging flag (or not) to CFLAGS
+ifeq ($(DEBUG),y)
+  DEBFLAGS = -O -g # "-O" is needed to expand inlines
+else
+  DEBFLAGS = -O2
+endif
+
+EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINCDIR)
+
+ifneq ($(KERNELRELEASE),)
+# call from kernel build system
+
+obj-m  := wb_to_wc.o
+
+else
+
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+PWD       := $(shell pwd)
+
+default:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINCDIR=$(PWD)/../include modules
+
+endif
+
+clean:
+       rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
+
+depend .depend dep:
+       $(CC) $(CFLAGS) -M *.c > .depend
+
+
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
diff --git a/root_image/drivers/wb_to_wc/wb_to_wc.c b/root_image/drivers/wb_to_wc/wb_to_wc.c
new file mode 100644 (file)
index 0000000..cd2439a
--- /dev/null
@@ -0,0 +1,53 @@
+#include <linux/module.h>
+#include <linux/kthread.h>
+#include <linux/pagemap.h>
+#include <linux/init.h>
+#define WB_TO_WC  "0.1"
+
+MODULE_AUTHOR("Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>");
+MODULE_DESCRIPTION("wb_to_wc_and_back");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(WB_TO_WC);
+
+#define MAX_PAGES 20
+static int thread(void *arg)
+{
+       struct page *a[MAX_PAGES];
+       unsigned int i, j;
+       do {
+               for (j = 0, i = 0;i < MAX_PAGES; i++, j++) {
+                       a[i] = alloc_page(GFP_KERNEL);
+                       if (!a[i])
+                               break;
+               }
+               set_pages_array_wc(a, j);
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout_interruptible(HZ);
+               for (i = 0; i < j; i++) {
+                       unsigned long *addr = page_address(a[i]);
+                       if (addr) {
+                               memset(addr, 0xc2, PAGE_SIZE);
+                       }
+               }
+               set_pages_array_wb(a, j);
+               for (i = 0; i< MAX_PAGES; i++) {
+                       if (a[i])
+                               __free_page(a[i]);
+                       a[i] = NULL;
+               }
+       } while (!kthread_should_stop());
+       return 0;
+}
+static struct task_struct *t;
+static int __init wb_to_wc_init(void)
+{
+       t = kthread_run(thread, NULL, "wb_to_wc_and_back");
+       return 0;
+}
+static void __exit wb_to_wc_exit(void)
+{
+       if (t)
+               kthread_stop(t);
+}
+module_init(wb_to_wc_init);
+module_exit(wb_to_wc_exit);