aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2015-09-22 13:10:56 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-10-26 04:49:42 -0400
commitd478b088a2f74fc8f34af7ceed86fa7640ca8610 (patch)
tree572d51384469da8a3bda7952f31e17fc5abfa6e9
parent75dcfc1d678d76a82288c043bfd5bfc0fbd43b49 (diff)
MIPS: Allow L2 prefetch to be configured via debugfs
When debugging or examining the performance of a system it can be useful to examine the effect of L2 prefetching. Provide an optional debugfs entry to allow a user to enable or disable L2 prefetching. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: Maciej W. Rozycki <macro@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/11182/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/Kconfig.debug10
-rw-r--r--arch/mips/mm/Makefile1
-rw-r--r--arch/mips/mm/sc-debugfs.c81
3 files changed, 92 insertions, 0 deletions
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 13d796547ebd..b43e288ec567 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -149,4 +149,14 @@ endchoice
149 149
150endif # CPU_MIPSR6 150endif # CPU_MIPSR6
151 151
152config SCACHE_DEBUGFS
153 bool "L2 cache debugfs entries"
154 depends on DEBUG_FS
155 help
156 Enable this to allow parts of the L2 cache configuration, such as
157 whether or not prefetching is enabled, to be exposed to userland
158 via debugfs.
159
160 If unsure, say N.
161
152endmenu 162endmenu
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 67ede4ef9b8d..b4c64bd3f723 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_IP22_CPU_SCACHE) += sc-ip22.o
28obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o 28obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o
29obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o 29obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o
30obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o 30obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o
31obj-$(CONFIG_SCACHE_DEBUGFS) += sc-debugfs.o
diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c
new file mode 100644
index 000000000000..5eefe3281b24
--- /dev/null
+++ b/arch/mips/mm/sc-debugfs.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@imgtec.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#include <asm/bcache.h>
12#include <asm/debug.h>
13#include <asm/uaccess.h>
14#include <linux/debugfs.h>
15#include <linux/init.h>
16
17static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
18 size_t count, loff_t *ppos)
19{
20 bool enabled = bc_prefetch_is_enabled();
21 char buf[3];
22
23 buf[0] = enabled ? 'Y' : 'N';
24 buf[1] = '\n';
25 buf[2] = 0;
26
27 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
28}
29
30static ssize_t sc_prefetch_write(struct file *file,
31 const char __user *user_buf,
32 size_t count, loff_t *ppos)
33{
34 char buf[32];
35 ssize_t buf_size;
36 bool enabled;
37 int err;
38
39 buf_size = min(count, sizeof(buf) - 1);
40 if (copy_from_user(buf, user_buf, buf_size))
41 return -EFAULT;
42
43 buf[buf_size] = '\0';
44 err = strtobool(buf, &enabled);
45 if (err)
46 return err;
47
48 if (enabled)
49 bc_prefetch_enable();
50 else
51 bc_prefetch_disable();
52
53 return count;
54}
55
56static const struct file_operations sc_prefetch_fops = {
57 .open = simple_open,
58 .llseek = default_llseek,
59 .read = sc_prefetch_read,
60 .write = sc_prefetch_write,
61};
62
63static int __init sc_debugfs_init(void)
64{
65 struct dentry *dir, *file;
66
67 if (!mips_debugfs_dir)
68 return -ENODEV;
69
70 dir = debugfs_create_dir("l2cache", mips_debugfs_dir);
71 if (IS_ERR(dir))
72 return PTR_ERR(dir);
73
74 file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir,
75 NULL, &sc_prefetch_fops);
76 if (IS_ERR(file))
77 return PTR_ERR(file);
78
79 return 0;
80}
81late_initcall(sc_debugfs_init);