0001
0002
0003
0004
0005
0006
0007 #include <asm/bcache.h>
0008 #include <asm/debug.h>
0009 #include <linux/uaccess.h>
0010 #include <linux/debugfs.h>
0011 #include <linux/init.h>
0012
0013 static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
0014 size_t count, loff_t *ppos)
0015 {
0016 bool enabled = bc_prefetch_is_enabled();
0017 char buf[3];
0018
0019 buf[0] = enabled ? 'Y' : 'N';
0020 buf[1] = '\n';
0021 buf[2] = 0;
0022
0023 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
0024 }
0025
0026 static ssize_t sc_prefetch_write(struct file *file,
0027 const char __user *user_buf,
0028 size_t count, loff_t *ppos)
0029 {
0030 bool enabled;
0031 int err;
0032
0033 err = kstrtobool_from_user(user_buf, count, &enabled);
0034 if (err)
0035 return err;
0036
0037 if (enabled)
0038 bc_prefetch_enable();
0039 else
0040 bc_prefetch_disable();
0041
0042 return count;
0043 }
0044
0045 static const struct file_operations sc_prefetch_fops = {
0046 .open = simple_open,
0047 .llseek = default_llseek,
0048 .read = sc_prefetch_read,
0049 .write = sc_prefetch_write,
0050 };
0051
0052 static int __init sc_debugfs_init(void)
0053 {
0054 struct dentry *dir;
0055
0056 dir = debugfs_create_dir("l2cache", mips_debugfs_dir);
0057 debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL,
0058 &sc_prefetch_fops);
0059 return 0;
0060 }
0061 late_initcall(sc_debugfs_init);