diff options
author | 2025-03-08 22:04:20 +0800 | |
---|---|---|
committer | 2025-03-08 22:04:20 +0800 | |
commit | a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a (patch) | |
tree | 84f21bd0bf7071bc5fc7dd989e77d7ceb5476682 /arch/mips/mm/sc-debugfs.c | |
download | ohosKernel-a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a.tar.gz ohosKernel-a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a.zip |
Initial commit: OpenHarmony-v4.0-ReleaseOpenHarmony-v4.0-Release
Diffstat (limited to 'arch/mips/mm/sc-debugfs.c')
-rw-r--r-- | arch/mips/mm/sc-debugfs.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c new file mode 100644 index 000000000..80ff39471 --- /dev/null +++ b/arch/mips/mm/sc-debugfs.c | |||
@@ -0,0 +1,61 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2015 Imagination Technologies | ||
4 | * Author: Paul Burton <paul.burton@mips.com> | ||
5 | */ | ||
6 | |||
7 | #include <asm/bcache.h> | ||
8 | #include <asm/debug.h> | ||
9 | #include <linux/uaccess.h> | ||
10 | #include <linux/debugfs.h> | ||
11 | #include <linux/init.h> | ||
12 | |||
13 | static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf, | ||
14 | size_t count, loff_t *ppos) | ||
15 | { | ||
16 | bool enabled = bc_prefetch_is_enabled(); | ||
17 | char buf[3]; | ||
18 | |||
19 | buf[0] = enabled ? 'Y' : 'N'; | ||
20 | buf[1] = '\n'; | ||
21 | buf[2] = 0; | ||
22 | |||
23 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | ||
24 | } | ||
25 | |||
26 | static ssize_t sc_prefetch_write(struct file *file, | ||
27 | const char __user *user_buf, | ||
28 | size_t count, loff_t *ppos) | ||
29 | { | ||
30 | bool enabled; | ||
31 | int err; | ||
32 | |||
33 | err = kstrtobool_from_user(user_buf, count, &enabled); | ||
34 | if (err) | ||
35 | return err; | ||
36 | |||
37 | if (enabled) | ||
38 | bc_prefetch_enable(); | ||
39 | else | ||
40 | bc_prefetch_disable(); | ||
41 | |||
42 | return count; | ||
43 | } | ||
44 | |||
45 | static const struct file_operations sc_prefetch_fops = { | ||
46 | .open = simple_open, | ||
47 | .llseek = default_llseek, | ||
48 | .read = sc_prefetch_read, | ||
49 | .write = sc_prefetch_write, | ||
50 | }; | ||
51 | |||
52 | static int __init sc_debugfs_init(void) | ||
53 | { | ||
54 | struct dentry *dir; | ||
55 | |||
56 | dir = debugfs_create_dir("l2cache", mips_debugfs_dir); | ||
57 | debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL, | ||
58 | &sc_prefetch_fops); | ||
59 | return 0; | ||
60 | } | ||
61 | late_initcall(sc_debugfs_init); | ||